Web Hosting Talk







View Full Version : PHP display Visitors ip address


ratchethosting
09-02-2006, 12:59 AM
Heres the problem i want php to display a visitors ip address, I have this code: echo "$_SERVER[REMOTE_ADDR]"; but the problem is when i have that same script in another directory like say for instance the images directory that code displays not the visitors ip but the servers ip. Is there a way to fix this?

Thanks

samdax
09-02-2006, 04:01 AM
On first page (where your script work correctly) create variable or even image, then on the rest of site use that variable/image instead of function
look here
http://www.allscoop.com/phpcode.php

mikey1090
09-02-2006, 09:30 AM
can you try $REMOTE_ADDR on its own?

horizon
09-02-2006, 05:42 PM
Two good ways you can show this up:


<?php
echo $_SERVER['REMOTE_ADDR']."<br />";
echo getenv('REMOTE_ADDR]');
?>


;)

ratchethosting
09-02-2006, 07:35 PM
ok ill try it...


thanks guys :)