Hi Friends I need example code in php that is used to find the location of the obtained remote ip address.
Hi Katypeterson. Do you mean you have already obtained the IP address and want a sample PHP code to trace its geographic location (i.e. details like city, country etc.)? Here you will find the sample codes: http://www.daniweb.com/web-development/php/threads/153705/php-script-to-find-visitors-location http://stackoverflow.com/questions/...ation-from-the-ip-entered-through-a-input-box http://stackoverflow.com/questions/409999/getting-the-location-from-an-ip-address http://www.a2zwebhelp.com/visitor-location-in-php (I am not a programmer myself, but often try to google solutions for my coder friends.) Hope this helps.
If you want a faster way of doing it without relying on third-party services, you can do it locally on your server with the GeoIP PHP extensions... http://www.php.net/manual/en/book.geoip.php
Hi. The simple code using find IP adress.... <?php if (getenv('HTTP_X_FORWARDED_FOR')) { $IP= getenv('HTTP_X_FORWARDED_FOR'); $CIP = getenv('REMOTE_ADDR'); echo "Proxy IP address is : ".$IP. "(via $CIP)" ; } else { $CIP= getenv('REMOTE_ADDR'); print"IP address is : $CIP"; } ?>
First - learn how to use code or php brackets around your code. Second, that could easily have been reduced to this: <?php echo $IP = (getenv('HTTP_X_FORWARDED_FOR')) ? 'Proxy IP address is:'.getenv('HTTP_X_FORWARDED_FOR').' (via'.getenv('REMOTE_ADDR').')' : 'IP address is: '.getenv('REMOTE_ADDR'); ?> PHP: One line. However, this does nothing of what the OP was asking for - this only shows the IP-address, it does not provide a location.