1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to get country name from ip address

Discussion in 'PHP' started by dineshsingh1984, Jan 7, 2015.

  1. #1
    I want to get the information that where the my website is open, i want to get the country name. how can do it?????????????
    i'm trying get the country name from ip address but i'm not getting any inforamtion......
     
    dineshsingh1984, Jan 7, 2015 IP
  2. Imgup

    Imgup Member

    Messages:
    67
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    I'd use an API, like: http://ipinfo.io

    
    function get_ip_details($ip){
    $fetch = file_get_contents('http://ipinfo.io/' . $ip);
    $return = json_decode($fetch);
    return $return;
    }
    
    $location   = get_ip_details($_SERVER['REMOTE_ADDR']);
    
    echo 'This IP originates from ' . $location->city . ' in ' . $location->country;
    
    PHP:
     
    Imgup, Jan 8, 2015 IP
  3. CubicleDropout

    CubicleDropout Peon

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    1
    #3
    https://www.maxmind.com/en/geoip-demo will give you location and hosting provider if you have a IP.
     
    CubicleDropout, Jan 8, 2015 IP
  4. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #4
    Anveto, Jan 8, 2015 IP
  5. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    usually from an ap unless you feel like making a database with all the IP ranges and the state /county
    in which case if you did you could probably sell that like the aps do.
    That would be good if it could imported to a database then your site makes no call out to an ap site.
    But have fun coding all that ..tedium.
     
    ezprint2008, Jan 12, 2015 IP
  6. Richard Clopton

    Richard Clopton Greenhorn

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #6
    By using Whatismyipaddress track country name from IP address.
     
    Richard Clopton, Jan 12, 2015 IP