Forum Moderators: coopster

Message Too Old, No Replies

How to display user's IP?

         

keyplyr

6:54 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What's the code to display?

"Your IP XX.XX.XX.XX has been logged."

Thanks

dmorison

7:00 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The super global holding the remote IP can vary slightly depending upon PHP version and configuration.

Best way is to study the output of phpinfo() on your server and check which global variable holds the remote IP address.

It is probably:

$_SERVER["REMOTE_ADDR"]

so your code would be:

echo("Your IP ".$_SERVER["REMOTE_ADDR"]." has been logged.");

keyplyr

8:49 pm on Aug 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks dmorison, that works fine.