Getting City and State by IP Address with PHP
A while back, I required a script like this one, but couldn’t find one that suited my exact needs, so I wrote one myself. Well, this year, I got bored and made an object out of it.
This script uses hostip.info to look up a user’s IP address and attempt to determine the city, state, country and geographical coordinates.
Hostip.info is a community-based project to geolocate IP addresses, but it requires that individuals in the area have put in their city and state for their IP address or IP range, so it’s not completely accurate unless people are involved. Go there and make sure your location comes up correctly, and if it doesn’t fix it, as this will help make the database more precise. Don’t worry, it’s just your city and state, not your address specifically.
Version 1.1 • 27k
Posted Friday, February 27th, 2009 at 4:29 pm in Scripts.