PHP Script to find visitor’s location

Hello All

Here is a simple php script that lets you track the location of the visitor’s on your site.

Lets get to the code straight away :

<?
$ip = '59.93.196.219';
$url = "http://www.ipmango.com/api.php?ip=".$ip;
$xml = simplexml_load_file($url);
echo "IP address : {$xml->ipaddress}";
echo "City : {$xml->city}";
echo "Region : {$xml->region}";
echo "Country Name : {$xml->countryname}";
echo "Latitude : {$xml->latitude}";
echo "Longitude : {$xml->longitude}";
?>

So basically what we did was, used the free geo ip api from IPMango

The syntax being http://www.ipmango.com/api.php?ip=a.b.c.d where a.b.c.d is the ip address.

Popularity: 7% [?]

Leave a Reply