You can use the GD library and the relevant PHP functions to generate images. This script is helpful to generate a security number image (CAPTCHA). Each time the page is refreshed a new number is Generated.
imagecreate() - Create a new palette based image,imagecreate() returns an image identifier representing a blank image of size x_size by y_size. (http://www.weberdev.com/imagecreate)
imagecolorallocate() - Allocate a color for an image. imagecolorallocate() returns a color identifier representing the color composed of the given RGB components. red, green and blue are the values of the red, green and blue component of the requested color respectively. These parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF. imagecolorallocate() must be called to create each color that is to be used in the image represented by image. (http://www.weberdev.com/imagecolorallocate)
imagefill() - Flood fill,imagefill() performs a flood fill starting at coordinate x, y (top left is 0, 0) with color in the image. (http://www.weberdev.com/imagefill)
imagerectangle() - Draw a rectangle,imagerectangle() creates a rectangle of color col in image image starting at upper left coordinate x1, y1 and ending at bottom right coordinate x2, y2. 0, 0 is the top left corner of the image. (http://www.weberdev.com/imagerectangle)
imagestring() - draws the string s in the image identified by image with the upper-left corner at coordinates x, y (top left is 0, 0) in color col. If font is 1, 2, 3, 4 or 5, a built-in font is used. (http://www.weberdev.com/imagestring)
imagejpeg() - creates the JPEG file in filename from the image image. The image argument is the return from the imagecreatetruecolor() function. (http://www.weberdev.com/imagejpeg)
The filename argument is optional, and if left off, the raw image stream will be output directly. To skip the filename argument in order to provide a quality argument just use a NULL value. By sending an image/jpeg content-type using header(), you can create a PHP script that outputs JPEG images directly.
random_number.php
<?php
global $number,$Scode;
$img_number = imagecreate(130,41);//Control side of Canvas
$white = imagecolorallocate($img_number,255,255,255);
$black = imagecolorallocate($img_number,0,0,0);
$grey_shade = imagecolorallocate($img_number,204,204,204);
imagefill($img_number,0,0,$grey_shade);
ImageRectangle($img_number,5,5,124,35,$black); //Control side of rectangle
ImageRectangle($img_number,0,0,129,40,$black); //Control side of rectangle
$Scode = $securitycode;
/*
techxcel, Open Source E-Commerce Solutions
Code by Chetankumar Akarte
*/
// Function : get_random
//
// Arguments : non
//
// Return : Random number
//
// Description : function for generate random number that use to conforms recure User Registration.
//
matthew waygood wrote :1678
Sorry, didn`t read the next page on that article. Change my comment from "Similar" to "Exactly"
Chetankumar Akarte wrote :1679
Hi..everybody
I have this script one year,when i was facing problem to generate Random Numbar using php, my friend VIJAY gave me the above script.
i have no idea that this Similar to http://www.developerfusion.co.uk/show/1951/4/
i feel that it is unique and created by my friend i requested him and told him that i want to submit it at http://www.weberdev.com... He reply that i can..!! so i submmited it with adding explanation of script
I heartily Thanks Matthew Waygood for giving me idea about real author of the script...
and i am very Happy to give the Credit to its real Author...
Please follow link for detail and original Author`s Creation at...
http://www.developerfusion.co.uk/show/1951/1/
Title:-Image Generation on the FLY using PHP
Thank you ance more Matthew Waygood to show me my mistake. i always care to avoid such mistake in future..