How do I Identify a Visitor's Country?

Discussion in 'PHP' started by Masterful, Sep 5, 2010.

  1. #1
    When visitors click on my links, I want to check which country they're in and redirect them to a destination based on their country. I know how to do the redirect, but I don't know how to identify the country.

    Can anyone help me, please?

    I conducted a bit of research and discovered that I have to download some kind of IP database. Can anyone explain what I have to do in more detail? I will appreciate it very much.
     
    Masterful, Sep 5, 2010 IP
  2. itmontreal.ca

    itmontreal.ca Peon

    Messages:
    13
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello Masterful,
    As you have noted this is done via IP addresses. First you need to get the IP address of the vistor via a php statement such as $ip=$_SERVER['REMOTE_ADDR']; Then you need a database such Geoip db (which could be found at maxmind.com/app/geoip_country

    Please have a look at :
    go4expert.com/forums/showthread.php?t=3511
    to see an example
     
    itmontreal.ca, Sep 5, 2010 IP
    mcfox and Masterful like this.
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    MyVodaFone, Sep 5, 2010 IP
    Masterful likes this.
  4. Masterful

    Masterful Well-Known Member

    Messages:
    1,653
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Thanks, guys. I'll check it all out.

    One rep point for each of you.
     
    Masterful, Sep 5, 2010 IP