<?php
$ip = '59.32.28.65';
$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 />";
?>

Hi theausum,

Two things:

Firstly, please use code tags when posting code. It really does make it a lot easier to read.
Secondly, did you have a question?

Sorry for not using the code tags.
I did not have any question.
I have just provided the php code to find visitor's location.

You know this thread is four years old. The site may no longer support the snippet above.

Depending on what you want to do but I use http://ip2location.com/ to generate a code for a iframe I use in the sidebar. It displays to visitors and appears to be tracking their IP address and server location. I get far less spam comments now even with Anti Spam measures in place. They have a page http://ip2location.com/developers with API info

if you want accurate geo location with low latency and the ability for the api to handle your websites traffic, the best solution out there is http://geolify.com .Geolify can also be used as a website personalization tool where you can deliver geo targeted content, images and url redirects with only a single line of javascript making it easy for website owners to geo target their website. If you just need location, you can use their geo javascript to determine country, state, city and coordinates very easily.

not this code is not working .....having error to open http stream

Warning: simplexml_load_file(htt/./ww.w.p:ipmango.com/api.php?ip=59.32.28.65): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\demo\demo2.php on line 4

no

Yea that tends to happen when you try to make a 6 year old snippet work. lol

i had tried this code but not working .....for accessing the information we have Geo
Api plugin ...ip address works perfect and country name also but another variable like city region not provide any appropriate value