Tesco - Cell Phones - Loans - Loans - Personal Loans

PDA

View Full Version : Obtaining users IP's with PHP


Weirfire
Oct 1st 2004, 6:34 am
I'd like to obtain users IP's so that I can calculate certain statistics on web site activity. Is there a method in PHP to log users IP's?

TwisterMc
Oct 1st 2004, 7:16 am
Like this... http://us2.php.net/getenv

Weirfire
Oct 1st 2004, 7:47 am
Thanks Twister.

Thats excellent. :)

TwisterMc
Oct 1st 2004, 8:39 am
Your welcome. :)

sarahk
Oct 2nd 2004, 1:35 am
or you can get it straight from $_SERVER
eg
$ip = $_SERVER['REMOTE_ADDR'];

and then use a database from someone like http://ip-to-country.webhosting.info/ to trace the ip to a country. It's very simple and effective to use. It looks good when someone fills in a form and you already have the country selected.

Sarah