Geolocation using PHP or HTML 5 location services?

I need to implement geolocation in a PHP-based app that I'm developing, and I'd like to know what the best way to go about it is.  

Based on what I've researched so far, .. doing a lookup based on IP address (using an API) is not always 100% accurate, .. and some lookup service providers are more reliable than others. Also, .. you're generally only able to identify the Country of the visitor, .. and not the precise location (ie: US State / City).  So .. I'm wondering if there might be a better way?

Does anyone here have any suggestions as to what the best way to implement something like this would be?  I'm looking for the most accurate and precise geolocation method possible (preferably something that identifies more than just the Country), .. and if it means that we have to subscribe to and pay for some service, .. that's ok.  

What about HTML 5's location services?  Is  there any way that I can leverage that?  

Any tips or advice (or code samples) would be greatly appreciated.

- Yvan

Who is Participating?
Mohamed AbowardaSoftware EngineerCommented:
This artical is helpful:

You might also consider subscribing with a company that provide this service so you can get the updates.
Ray PaseurCommented:
Have not used HTML5.  I have used GEOIO with great success.  Free for low-level use, modest charge for high-level use.  Example of a map drawn from a data base of GEOIO responses is here:

In that map I intentionally limit the geocode information to DECIMAL(8,4) with a UNIQUE index on lat, lon columns to keep the map from becoming cluttered.  Greater accuracy - right to the rooftop - is achieved with DECIMAL(10,6).

GEOIO is here.  Get an API key and you can start testing within seconds.

In my app I decoupled the GEOIO part from the rest of the web site.  I get the client's IP address and POST a script that uses GEOIO information to update my data base.  I do not wait for the POST to complete and I do not care if the GEOIO service fails or rejects my request.  YMMV on this point!
Marco GasiFreelancerCommented:
You can find simple free service here: Once you are registered, you get a free key to use in very simple code

For city:<your_api_key>&ip=

For country:<your_api_key>&ip=

Here you find a little script to get data and echo them ina page.

egoselfaxisAuthor Commented:
Thanks guys!  This is exactly what I was looking for.

- Yvan
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.