Jump to content

[SOLVED] IP address / proximity lookup script


boo_lolly

Recommended Posts

I'm trying to see how to write a script that can read the current user's IP, and reverse check to see the physical location (country, city, state, zip... whatever I can get) of the current user. I've seen a couple of sketchy sites that do it out there, already, but I need this information to be calculated on my server so I can store this information into a database, along with the IP address, simultaneously. So I was wondering, first, if it would be better to write this script on my own, or if I should use curl to communicate with one of the websites that can already does this. Second, how would I do either one of them? Not familiar at all with curl, and I'm not sure where to begin if I were to write it myself.

 

The most useful of the websites I have found that do this is here: http://www.find-ip-address.org/  (it's pretty accurate. gets me within 10 miles of my actual current location.)

 

Can I get some help with this?

Link to comment
Share on other sites

You can retrieve the visitors IP address using $_SERVER variables, namely..

 

$ip=$_SERVER['REMOTE_ADDR'];

 

Now that you have the IP you can query a database online that is updating to locate the IP to a physical region.

 

If you check out the following link he explains how he implemented this onto his site.

 

http://www.yougetsignal.com/tools/network-location/

Link to comment
Share on other sites

I found a great deal of information from that link. Thanks!

 

first, for a commercial ip/geo-locator service you can go to http://www.maxmind.com/app/geolocation which is known to be incredibly accurate.

 

second, for a free ip/geo-locator service you can use a very simple http request using http://www.hostip.info/use.html . This website is not always accurate. however, when it encounters an ip that it can't locate, it requests the end user to provide their location. Don't you just love open-source?

 

Thanks again!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.