• Skip to main content
  • Skip to primary sidebar

AllScoop

Gadgets - PHP Code - ASP Code - Web Tools - Technology

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

Filed Under: php code Tagged With: graphic, IP, PHP

Reader Interactions

Comments

  1. lisa says

    May 23, 2011 at 4:46 am

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

    • lisa says

      May 23, 2011 at 4:56 am

      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

    June 10, 2011 at 11:57 am

    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

    July 15, 2011 at 11:22 am

    thank for this script ^_^

  4. Richard Yazmajian says

    October 31, 2011 at 3:59 pm

    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

    • allscoop says

      November 2, 2011 at 9:03 am

      That information is best obtained from your server logs.

  5. Oemar says

    March 17, 2012 at 4:18 pm

    nice script.

    thanks 4 share. 😀

  6. Ian says

    March 18, 2012 at 11:37 am

    Thank you so much guys.

    I’m loving this.

  7. AlAa YoSeF says

    March 21, 2012 at 11:33 am

    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

    September 29, 2012 at 11:43 am

    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

    December 19, 2012 at 11:16 am

    Just put this on your page where you want it.

    ” YOUR IP IS: ”

    😉 Easy & Simple

  10. kata mutiara says

    December 26, 2012 at 2:44 pm

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

  11. Putupunyablog says

    December 27, 2012 at 7:54 am

    Thanks.. i like it 🙂

Primary Sidebar

Categories

  • allscoop
  • antenna
  • appliance repair
  • asp scripts
  • bots
  • cars
  • code
  • ecommerce
  • hardware
  • misc
  • mobile
  • news
  • other stuff
  • php code
  • projects
  • seen on tv
  • shopping cart
  • software
  • technology
  • the web
  • tools
  • wordpress

Blogroll

  • Air Quality Test
  • Cartridge Library

Resources

  • Cool Stuff
  • Ohio Business
  • Timeclock Software
  • Wiper Blades

Pages

  • 1&1 Business Package Review
  • About AllScoop

Copyright © 2022