<?php
Session_Start ();
Generate Captcha Picture
Header ("Content-type:image/png");
$im = Imagecreate (44,18); Draw a picture that specifies the width and height
$back = Imagecolorallocate ($im, 245,245,245); Define background color
Imagefill ($im, 0,0, $back); Fill the background color into the picture you just drew.
$vcodes = "";
Srand (Double) microtime () *1000000);
Generate 4-digit numbers
For ($i =0 $i <4; $i + +) {
$font = Imagecolorallocate ($im, Rand (100,255), Rand (0,100), Rand (100,255)); Generate Random Colors
$authnum =rand (1,9);
$vcodes. = $authnum;
Imagestring ($im, 5, $i *10, 1, $authnum, $font);
}
$_session[' vcode ' = $vcodes;
For ($i =0 $i <100; $i + +)//Add interference pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor); The function of the element point of portrait
}
Imagepng ($im);
Imagedestroy ($im);
?>