Display visitors IP in an Image

Submitted by:Jhon Brain

Date added:21 May, 2012

Category:PHP

How to display visitors IP in an Image using PHP

Tags: display ip

Code Snippet:

    <?php  
//Creating the image
header ("Content-type: image/gif");
$image=imagecreatefromgif("imageboard.gif");

//Making some colors
$black = imagecolorallocate($image, 0,0,0);

//Getting the user's IP address and text to display
$ip_address = $_SERVER['REMOTE_ADDR'];
$message = "Your IP is:";

//Displaying IP address on the image.
imagestring($image, 4, 25, 10, $message, $black);
imagestring($image, 4, 20, 27, $ip_address, $black);

//Creating the image, then removing it from memory
imagegif($image);
imagedestroy($image);

?>
 
 

Comments