Forum Moderators: coopster

Message Too Old, No Replies

browser IP

         

yllai

2:59 am on Oct 17, 2007 (gmt 0)

10+ Year Member



Hi all,

Anyone know how to capture user computer IP?
As I know "GetHostByName" is used to capture host IP, how about capture user computer's IP? Any guide?

eelixduppy

4:33 am on Oct 17, 2007 (gmt 0)



It's usually in the predefined variable
$_SERVER['REMOTE_ADDR']
. Echo it to your browser and see what you get :)

yllai

5:41 am on Oct 17, 2007 (gmt 0)

10+ Year Member



thanks...I got it.

PHP_Chimp

7:39 pm on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As eelixduppy said 'usually' in $_SERVER['REMOTE_ADDR'], but there are some weird ones that seem to be used by some servers (im not sure if they are specific to anyone, but they sometimes appear in the $_SERVER array).

$_SERVER['HTTP_CLIENT_IP']
$_SERVER['HTTP_X_FORWARDED_FOR']
$_SERVER['HTTP_X_FORWARDED']
$_SERVER['HTTP_FORWARDED_FOR']
$_SERVER['HTTP_FORWARDED']

Using all of those I dont think I have ever not managed to collect an IP address...unfortunately sometimes you get more than 1 :(