Alright kids,

I know next to nothing about PHP but I'm interested in geolocation scripts. A couple of months ago, I got a presentation from a company that can target content down to the zip code level (and much more, but that's beside the point). However, what they charge a month is just too much for our campaign's budget and I'd like to see if I could replicate something similar. Everything I've read leads me to believe I'd need PHP. This company, however, gives their clients a simple javascipt code to plop on their site after the user uploads the various images in the database and sets parameters for each one (ie show this image for this zip).

Couple of questions
1. I keep hearing geolocation can be a headache and is often wildly inaccurate. True?
2. Is it possible to replicate something like this? I would purchase the IP database from maxmind...they have zip code data for Ips.
3. Last - would the easiest solution be to have visitors enter their zip code before the website loads and just customize the content that way? Or would that be a pain for the visitor (this is a political website).

Thanks!

This is one example of an open source class to do geolocation. I can't say how well it works as I haven't used it personally. You can probably do a search and finds others.
http://www.phpclasses.org/package/3813-PHP-Get-the-location-of-an-IP-address-with-the-hostip.html

Since you have already identified maxmind as part of your solution, you have probably already done some research. Here is an article that talks about the accuracy and issues for geolocation with maxmind as their solution as well.

http://www.chehodgins.com/php/free-and-fast-geolocation-in-php/

With respect to your question 3, why not do the geolocation and then ask the user to press enter to confirm it or allow them to make changes to it? That way it is minimal effort in most cases but when it is wrong, they do get the chance to correct it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.