Click to See Complete Forum and Search --> : can php detech IP address of users?


lting
05-12-2004, 11:17 PM
i want to do a audit trail, and save the IP address users into my database ... is there any php functions or statements that allow me to get users IP address?

Paul Jr
05-12-2004, 11:47 PM
You can access it through the REMOTE_ADDR property of the $_SERVER (or $HTTP_SERVER_VARS) superglobal.

If you are using PHP version 4.1.0 or above, you access it like this:

<?php
echo $_SERVER["REMOTE_ADDR"];
?>

But if you are using a version of PHP below 4.1.0, then you access it like this:

<?php
echo $HTTP_SERVER_VARS["REMOTE_ADDR"];
?>

You can find some more info here (http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server).

lting
05-13-2004, 12:21 AM
thanks it works well :)

Paul Jr
05-13-2004, 12:43 AM
You’re welcome. :)