Many times we have received the private mails requesting the help to track the IP address of the users. Here is a simple php code to get the IP address of the user. With a little addition to the code, you can get the location details of the user like Country, State and city. Please see the code below.
Usage
Now to show the IP use
<?php echo getIP();?>
How to get the location details from IP?
To get the location details like city, state, country, latitude, longitude etc.. from IP address of user, use the following code along with the above.
Thats it. If you have some alternate ways for getting these details, please post it below.
Tags: convert ip to city, convert ip to location, easy ip location, find ip address, get user ip, how to locate ip, ip to country, ip to state, location from ip address, php ip detection, track user ip
hi Aqeel,
This code seems not producing ny result.
Have u tried testing this recently ?
cheers
Its working. Which part of the code is not working for you?
Hi
I am tracking website user but after some time i am getting result
“Limit Exceeded”.
but do not show “Limit Exceeded” how do this
Regards and Thanks
Satya
Email -Id: satya2000chauhan@gmail.com
Check whether you exceeded the Geocode limits.
Hi i tried out this code,
The IP address which i am receiving from the above code is different from my real IP address
I have crosschecked and its displaying “NULL” when i used the same code and tested it online
It’s not working. it says “Error getting meta tags”
Please check this ip address 174.113.193.213 which is location Toronto,Canada but this api shows it in US.
Not sure about why the error happens. Probably an issue with service provider. Please report this bug to the service provider.
Parse error: syntax error, unexpected ‘if’ (T_IF) in D:\xampp\htdocs\employee\a.php on line 17
@Jasmeet, unexpected ‘if’ on line 17 means your issue is on line 16. Check whether you missed an “;” at the end of line 16.
this code display unknown address of my own ip(from india rajkot)
reply me fast
Please check this ip address 174.113.193.213 which is location Toronto,Canada but this api shows it in US.
Great Sir,
Thankful with Grateful Heart….
Hi,
Its working for me.
thanks
Thanks for reporting.
Thanks very much, it worked for me and you just saved me after hours of research but some result gives a different values compared to other sites
it is not working for me. its say Notice: Undefined index: city in C:\wamp\www\geo\index.php on line 45
please any body give solution.