I want my site to be able to locate a computers location, so if someone is accessing my site from london or manchester etc and to have users from a certain area displayed depending on their computers location. kind of like an online dating site that suggests users in your area.
I have been looking at this GEOIP database that lists all the cities around the world. But i dont know what to do next? Do i need to look at get ip address scripts that pull and compare the information from the GEOip database?
Please can someone point me in the right direction. Thanks.
GeoIP database from: http://dev.maxmind.com/geoip/geolite
It depends on your need. I would suggest you use a web service so you do not need to worry about hosting the database and maintaining it on your own. All you need to do is parse the IP address of your visitor and get the result instantly. I am using the IP2location web service from this site.
I've used this one in PHP on my site. Very quick and easy to digest (xml etc): http://www.geoplugin.com/
Please note, this database is:
In our recent tests, the GeoIP databases tested at 99.8% accurate on a country level, 90% accurate on a state level in the US, and 83% accurate for cities in the US within a 40 kilometer radius.
I would look into something like the: PEAR GeoLite library
A quick snippet of using this library in php:
The output will show, something similiar to:
You probably already have GEOIP installed as a PECL extension. If you don't, then you can just install it yourself.
If you need anything more specific than country, you'll have to pay to get the DB, but the functions are still there.
Try the below code.
Dont try this in your localhost. It will give the ip 127.0.0.1.
You can use the services of https://geoip-db.com. A php JSONP example that returns the location of a given IP address.