Re: IP address reference
| From: | Christian Blichmann | Date: | Wed, 13 Feb 2002 18:16:15 +0000 |
| Subject: | Re: IP address reference | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-12059@lists.php.net to get a copy of this message | ||
Hi there!
I am using this code to get the users IP, it also allows you
to retrieve the IP of AOL users.
Btw, the @ before $_SERVER["HTTP_X_FORWARD_FOR"]
prevents an error message, if the user is not using AOL...
Oh, I almost forgot: The $ip variable is an integer (I did this for
efficiently storing the IP in an MySQL database).
// Get user's IP and user agent
$ip = ip2long(($tmp = @$_SERVER["HTTP_X_FORWARD_FOR"]) ? $tmp :
$_SERVER["REMOTE_ADDR"]);
Hope it helps,
--
Christian Blichmann
_____________________________________________
don't hesitate - email me with your thoughts:
e-mail: feedback.nospam@blichmann.de
- please remove the ".nospam" from address.
_____________________________________________
do you want to know more?
web: http://www.blichmann.de