Find visitor IP, Country, Latitute and longitute using PHP

Discussion in 'PHP' started by samirkumardas, Aug 11, 2008.

  1. #1
    How can I find visitor IP, Country, Latitute and longitute using PHP?

    Any reference or help?
     
    samirkumardas, Aug 11, 2008 IP
  2. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Aside from coding you will need to subscribe to a service that provide the information. I haven't used any paid services myself but I would suggest something like geobytes.com as their info looks pretty complete.

    You could start with a free service like hostip.info but the information is basic, not always 100% correct and sometimes missing ...

    Either way you will need to get the browser IP address and then do the lookup:

    
    $mybrowser = "http://api.hostip.info/get_html.php?ip=" . $_SERVER['REMOTE_ADDR'];
    $mygeoinfo = file_get_contents($mybrowser);
    echo $mygeoinfo;
    
    PHP:
     
    mallorcahp, Aug 11, 2008 IP
  3. Nevadasam

    Nevadasam Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    I use the free look up services of geobytes.com. As mentioned you will need to acquire the visitor's IP. In order to keep my script from linking with the service so much, I slowly build up my own data base which is checked against first before finding any information not in the data base.

    Good Luck!

    Sam
    ;
     
    Nevadasam, Aug 11, 2008 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    mwasif, Aug 11, 2008 IP
  5. samirkumardas

    samirkumardas Banned

    Messages:
    123
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Guys,

    thanks for the reply. Client do not want a free service. At this moment, only country is enough. I found a latest database for converting IP to country. I like their mechanism.

    http://software77.net/

    Thanks
     
    samirkumardas, Aug 11, 2008 IP
  6. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #6
    geobytes aint that good, i recommend or maxmind or hostinfo!!!
     
    EricBruggema, Aug 11, 2008 IP
  7. LaZyBuM™

    LaZyBuM™ Peon

    Messages:
    183
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You can use cURL to get data from ip2location.com
     
    LaZyBuM™, Aug 11, 2008 IP
  8. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I know a good website that provide free script to get the country, it don't use a database, just some files and the installation is very easy, 20 lines of scipts, but I can't post a link here, I will post it when I will have more than 10 posts. :)
     
    Ilyes, Aug 12, 2008 IP
  9. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #9
    you don't have to provide al link, give us the filename and wi'll find it :)
     
    EricBruggema, Aug 12, 2008 IP
  10. Syndication

    Syndication Active Member

    Messages:
    351
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    90
    #10
    I believe GeoIP has an API you can integreate with PHP
     
    Syndication, Aug 13, 2008 IP
  11. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #11
    Did you look at GeoIP that I have mentioned in my last post? If you want to pay them, they will definetly accept it with thanks:). They have a paid service too, and you will get frequent updates as well.
     
    mwasif, Aug 20, 2008 IP
  12. pijussaus

    pijussaus Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You can find Finhised scripts on google , Example: Whatsmyip
     
    pijussaus, Aug 20, 2008 IP
  13. lovelycesar

    lovelycesar Peon

    Messages:
    145
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    There is complete example in PHP on my site. Easy to install & integrate into your PHP pages. Just 2 minutes to finish your work.
     
    lovelycesar, Aug 20, 2008 IP
  14. gezzle

    gezzle Peon

    Messages:
    108
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #14
    gezzle, Aug 21, 2008 IP