WEB [php] get the users state based on IP

Discussion in 'OT Technology' started by intrktevo, Oct 19, 2008.

  1. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
    What's the best method for php, to get the user's state based on their IP?
     
  2. sharp65

    sharp65 OT Supporter

    Joined:
    Feb 26, 2007
    Messages:
    378
    Likes Received:
    0
    Location:
    Boston
    Just did a quick search on google and found this. I did some quick tests by appending my IP address to the end of the URL and it did match my city. It will be more accurate if the person is in a larger city versus a smaller one. But it includes a php function to return the location. There may be a better way out there, this is just the first that I found.

    http://www.linuxjournal.com/article/7856
     
  3. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
    it says im from australia :hsugh:
     
  4. biawokauns

    biawokauns New Member

    Joined:
    Sep 18, 2001
    Messages:
    19,893
    Likes Received:
    0
    Location:
    Republic of Kalifornia
    use one of the geokit apis out there. let me see if i can dig up some more info
     
  5. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    it might be easier just to read a cookie or saved form data where they probably entered their zip code or state or another web site

    I always thought that was how web advertisements targeted specific locations.. or is that done by IP?
     
  6. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
    i was looking at http://www.maxmind.com/app/php but it seems like a lot of stuff just to get the users state. i would of thought there was some easy solution.

    the link sharp posted looking promising but I keep getting a permission denied error when i try to integrate it
     
  7. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
    no idea, but i'd be interested in finding out
     
  8. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    Easy.

    1) Use the GeoIP.php class from here.
    2) Get the Data file from here.
    3) ???????
    4) Success!
     
  9. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    12
    Location:
    Toronto
    Best way. Once its installed, its a single line of code to get any data you want from an IP.
     

Share This Page