depojones Posted April 11, 2009 Share Posted April 11, 2009 Hi folks, Is it possible to get the location of an IP address in PHP example: Your IP address is : 127.0.0.1 Your City is: Hell Thanks in advance Link to comment https://forums.phpfreaks.com/topic/153611-advance-ip-info-using-php/ Share on other sites More sharing options...
runnerjp Posted April 11, 2009 Share Posted April 11, 2009 ok you would have to have ur db filled with ip and locations ect... so a quick way is to use anouther site and pull there results like so <? $ip = '59.93.196.219'; $url = "http://www.ipmango.com/api.php?ip=".$ip; $xml = simplexml_load_file($url); echo "IP address : {$xml->ipaddress} <br />"; echo "City : {$xml->city} <br />"; echo "Region : {$xml->region} <br />"; echo "Country Name : {$xml->countryname} <br />"; echo "Latitude : {$xml->latitude} <br />"; echo "Longitude : {$xml->longitude} <br />"; ?> Link to comment https://forums.phpfreaks.com/topic/153611-advance-ip-info-using-php/#findComment-807179 Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 11, 2009 Share Posted April 11, 2009 For the ip address use $_SERVER['REMOTE_ADDR'] For the city there no function for that. You will have to find a database make a script for it. MaxMind have a nice database of IP address with ISP/City/Latitude-Longitude/... http://www.maxmind.com/app/ip-locate or you can ask google maybe someone made a API or offer a service for that Link to comment https://forums.phpfreaks.com/topic/153611-advance-ip-info-using-php/#findComment-807181 Share on other sites More sharing options...
depojones Posted April 11, 2009 Author Share Posted April 11, 2009 OK guys. I was thinking of that too. I thought there was a function that displays the city / state for an IP. Thanks anyway Link to comment https://forums.phpfreaks.com/topic/153611-advance-ip-info-using-php/#findComment-807218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.