Support Forums

Full Version: Mini PHP Project
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Just reads the IP address and source I came from??
Anyway, at least the song is pretty Tongue
And the time aswell, but still need to sort that out.
(09-04-2011, 07:00 AM)BreShiE Wrote: [ -> ]And the time aswell, but still need to sort that out.

You're not going to be able to accurately get the time for each user using PHP. Not without having them tell you their timezone, at least.

JavaScript might work, though.
Actually, The time() function in PHP grabs the time of the server it is hosted on. In this case, it is showing 3:15 pm for me because the server is hosted in the eastern time zone while I am in the Central time zone. It is a good start to learn PHP.

Getting the persons IP address is also quite simple. 2 Lines of code can simple get your IP address and display it:

Code:
<?php

$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;

?>

Basic as that. But i do like the skull head btw Big Grin
(09-04-2011, 12:17 PM)FritoBandito Wrote: [ -> ]Actually, The time() function in PHP grabs the time of the server it is hosted on. In this case, it is showing 3:15 pm for me because the server is hosted in the eastern time zone while I am in the Central time zone. It is a good start to learn PHP.

Getting the persons IP address is also quite simple. 2 Lines of code can simple get your IP address and display it:

Code:
<?php

$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;

?>

Basic as that. But i do like the skull head btw Big Grin

The "skull head" is the troll face, how didn't you know that?

Also you can cut that down to one line as I did.

PHP Code:
<?php

echo $_SERVER['REMOTE_ADDR'];

?>
You should make the clock count by the seconds. Instead of having to refresh the page to see the time change.
(09-04-2011, 01:37 PM)BreShiE Wrote: [ -> ]The "skull head" is the troll face, how didn't you know that?

lol my bad. Wasn't paying that much attention...

And that works too, but what if you want to use the $ip variable later on? :O. Like....to make a logger on who comes on your website. Tongue

(09-04-2011, 01:41 PM)alabama Wrote: [ -> ]You should make the clock count by the seconds. Instead of having to refresh the page to see the time change.

Or use javascript Tongue.
(09-04-2011, 01:50 PM)FritoBandito Wrote: [ -> ]lol my bad. Wasn't paying that much attention...

And that works too, but what if you want to use the $ip variable later on? :O. Like....to make a logger on who comes on your website. Tongue

Then you can still use $_SERVER['REMOTE_ADDR']

;)
Really simple.
I'm learning PHP and this is similar to my first project.
I made an IP logging script which added it to a mysql database.
(09-04-2011, 05:13 PM).edit Wrote: [ -> ]Really simple.
I'm learning PHP and this is similar to my first project.
I made an IP logging script which added it to a mysql database.

I think everyone starts with an IP logging script. Not a bad thing, really; if you make a half-decent one, you can learn quite a bit.
Pages: 1 2 3