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.

PHP script for ip lookup

Discussion in 'PHP' started by prensa.artistas, Dec 2, 2009.

  1. #1
    Hi,

    I'm looking for a PHP script that will reflect the user's ip on my website .
     
    prensa.artistas, Dec 2, 2009 IP
  2. Xexi

    Xexi Well-Known Member

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    100
    #2
    Please use the 'Search' function before asking for help.

    Guidelines, Tips & Frequently Asked Questions -> 1. GUIDELINES -> 1.6 Search before you post:
    Before you post a new thread, search the forum. Chances are a similar question has already been answered.

    It's also expected that you at least do a google search as well.


    The truth is, people wont help anyone who isn't willing to put at least some effort into the problem they ran into.
     
    Xexi, Dec 2, 2009 IP
  3. w3goodies

    w3goodies Member

    Messages:
    94
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    If you haven't found your answer... Here you go:

    <?php
    $ip = $_SERVER['REMOTE_ADDR'];
    echo "Your IP: " . $ip;
    ?>
    PHP:
     
    w3goodies, Dec 2, 2009 IP
  4. sloddl

    sloddl Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    echo $_SERVER['REMOTE_ADDR'];
     
    sloddl, Dec 3, 2009 IP
  5. mutley

    mutley Peon

    Messages:
    356
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i got an full script that i made that dose this i use it to sell products to diffet people on where they live let me now if you need this script as i made this script and it took me time to make maybe we could come up with an price
     
    mutley, Dec 4, 2009 IP
  6. freezea

    freezea Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <?php
    $img_number = imagecreate(275,25);
    $backcolor = imagecolorallocate($img_number,102,102,153);
    $textcolor = imagecolorallocate($img_number,255,255,255);

    imagefill($img_number,0,0,$backcolor);
    $number = " Your IP is $_SERVER[REMOTE_ADDR]";

    Imagestring($img_number,10,5,5,$number,$textcolor);

    header("Content-type: image/jpeg");
    imagejpeg($img_number);
    ?>
     
    freezea, Dec 4, 2009 IP
  7. taminder

    taminder Peon

    Messages:
    581
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you can just get their range and redirect to a diff page depending on where they live.
     
    taminder, Dec 5, 2009 IP
  8. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    good job
    but i think he want to know the online users ip?
     
    astkboy2008, Dec 6, 2009 IP
  9. Xexi

    Xexi Well-Known Member

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    100
    #9
    The idea of having people search for the resolution to their problem themselves is to have them view what others have done, *hopefully* giving them new ideas on what they want to do.

    <?php
    if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
    else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv ("HTTP_X_FORWARDED_FOR");
    else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
    else $ip = "UNKNOWN";
    ?>
    PHP:
    The above code attempts to find the environment variable via getenv() of the clients IP address, and if not found will try and resolve the forwarded for IP address. Last it checks the remote address if the user is using a proxy.
     
    Xexi, Dec 6, 2009 IP