Adding Geolocation with country and state to my PHP script.

Discussion in 'PHP' started by Cakk15, Jul 13, 2011.

  1. #1
    I have the rest of the code all I need now is the location help is much appreciated.



    <?php
    $ipz0r= $_SERVER[REMOTE_ADDR];
    $pagez0r = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
    $referrerz0r = $_SERVER['HTTP_REFERER'];
    $datetimez0r = date('l jS \of F Y \a\t h:i:s A');
    $useragentz0r = $_SERVER['HTTP_USER_AGENT'];
    $remotehostz0r = @getHostByAddr($ipz0r);
    $bodyz0r = "IP: " . $ipz0r . "\n\nPage: " . $pagez0r . "\n\nDate: ". $datetimez0r . "\n\nUser Agent: " . $useragentz0r . "\n\nRemote Host: " . $remotehostz0r;
    mail("@gmail.com","CPCT RE", $bodyz0r);
    echo "";
    ?>
     
    Cakk15, Jul 13, 2011 IP
  2. VideoWhisper.com

    VideoWhisper.com Well-Known Member

    Messages:
    330
    Likes Received:
    6
    Best Answers:
    2
    Trophy Points:
    113
    Digital Goods:
    2
  3. thedark

    thedark Well-Known Member

    Messages:
    1,346
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    168
    Digital Goods:
    1
    #3
    The best way to show the state and city is to use an IP Address lookup api service. All you have to do is to request an API key, receive all the info by email and add the code to your website.
     
    thedark, Jan 30, 2012 IP