Resolving an IP address to a hostname, or reverse DNS, has been around for a while. However, resolving an IP address to a physical location, or geocoding, has just recently come into its own.
However, most people want something that they can simply plug into their web site that will tell visitors where they’re located. Companies such as Quova, Akamai, and MaxMind provide IP-to-location services of varying resolution and accuracy. Except for a few flukes (e.g. all AOL users are in Virginia!), these services are fairly good.
This results in a tiny script that prints the user’s city, inline:
One caveat: to support this service, GeoBytes occasionally shows an advertisement instead of your own page, about once every 50 page views. This is unfortunate, so I’m looking for an ad-free replacement along the lines of InternetFrog.