Show users IP in a graphic – PHP Script

Show IP
Display visitor’s IP Address in a graphic with this simple php code.

(Please do not link to this image, it is for demonstration only.)

Your IP Address

create a new page, copy the text below and save it as image.php (or whatever you wish)

All you’ll need to display on other pages is the code below.

<img src=”http://yoursitehere.com/image.php” border=”1″>

note: this code will only on systems that support GD image tools

13 Responses to “Show users IP in a graphic – PHP Script”

Read below or add a comment...

  1. lisa says:

    Thank you for this code. How can a background image be used?

    • lisa says:

      I got it

      $img_number = imagecreate(110,24);
      $image = imagecreatefromgif(‘image.gif’);
      $backcolor = imagecolorallocate($img_number,254,46,212);
      $textcolor = imagecolorallocate($image, 0, 0, 0);

      imagefill($image,0,0,$backcolor);
      $number = $user['position'];
      Imagestring($image,9,26,4,$number,$textcolor);
      header("Content-Type: image/gif");
      imagegif($image);
      ImageDestroy($image);

  2. csstener says:

    Would it be best if you used: if(!empty($_SERVER['HTTP_CLIENT_IP']))

    {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
    }
    elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
    {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
    $ip = $_SERVER['REMOTE_ADDR'];
    }

    To get the ip??

  3. sarto says:

    thank for this script ^_^

  4. Richard Yazmajian says:

    Hi,
    I want to find out who and which IP addresses are clicking on my web site in order to block click fraud and solicitors.
    Can you help me?
    Thanks
    Richard

  5. Oemar says:

    nice script.

    thanks 4 share. :D

  6. Ian says:

    Thank you so much guys.

    I’m loving this.

  7. AlAa YoSeF says:

    Hi every one my name is AlAa

    My problem with $_SERVER['remote_addr']

    I’m not sure if I’m having a problem with the installation of PHP on the server or if there’s something that I’m not doing right in the code, but I am trying to capture the IP address of anyone that is trying to log into a secure part of a site. Regardless of my IP address, when I do:

    Code:

    echo $_SERVER['remote_addr'];

    It returns ’192.168.1.1′. This is the first time I’ve written code that is being used on a Windows Server, so I don’t know if that has anything to do with it.

    I’ve run phpinfo(), and in the PHP Variables section, it shows “_SERVER["REMOTE_ADDR"]” : 192.168.1.1. Does this mean that the php.ini file is setup wrong, or am I missing something?

    i am running my own server on windows 7 iis7.5 with php as fastcgi and i am behind a router with a dynamic ip not static and i am using
    http://www.no-ip.com/ that give me a link to my router and i am opening 80 port in my router forwarding it to my id address 192.168.1.5 and i have tested a php file that contains

    tested it using tor network that give me ip out of my network to test that file always give me the same result 192.168.1.1 i am trying to get IP address of the visitor and i asked someone of my friends to use this form it sends the same ip

    i hope someone tells me what i am doing wrong and the solution for this problem

    Thanks in advance

  8. Routers says:

    allscoop,
    thanks for the scripts

    AlAa YoSeF

    this will happen if you check your scripts from your LAN
    try to go home and call your server scripts from home

    FYI ($_SERVER[REMOTE_ADDR]“;) is not to show the server ip
    its to show the client public IP

    regards

    Routers/MY

  9. LG says:

    Just put this on your page where you want it.

    ” YOUR IP IS: ”

    ;) Easy & Simple

  10. kata mutiara says:

    Php code is really confusing.. but thanks you make me easy to understand :)

  11. Putupunyablog says:

    Thanks.. i like it :)

Leave A Comment...

*