Worth noting is that IP-based geolocation is not at all accurate under many common cases. Here's five IP geolocation results within a few miles of each other:
My work computer: Florida
Tim Hortons WiFi near my office: Vancouver, BC, Canada
My cellphone: Detroit, Michigan
My home desktop computer, left-most monitor: Rochester, New York
My home desktop computer, right-most monitor: New York City, New York
Most accurate is using
HTML5 Geolocation to ask the user's device to disclose its location. However, the user must give their consent before their location will be provided, and if they're using a device without GPS, it's going to be a crapshoot anyway (probably falling back to IP-based geolocation).
In short, there's no correlation between where a user is and where their IP address suggests they are, or even any guarantee that an IP address will only emit traffic originating from one geographic area. (Consider NASA's firewall... it's got
a space station full of people and an entire planet inhabited solely by IP-enabled robots behind it, not to mention zillions of employees everywhere from Antarctica to Ohio. Headquarters is Washington, DC, so that's probably where their Internet bill goes. Choose that.) Your plan is not an uncommon one, but it is not possible given the Internet's design.
_________________
Code:
/* TODO: need to add signature to posts */