PHP generated Verification code file is a learning PHP friends should know the technology oh, this can not only make your site security to improve some, you can also note some machine registration and other problems Oh, below we will look at a simple generation code program
PHP generated Verification code file is a learning PHP friends should know the technology oh, this can not only make your site security to improve some, you can also note some machine registration and other problems Oh, below we will look at a simple generation code program
!--?
/ecknum.php
Session_Start ();
function Random () {
$srcstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Mt_srand ();
$strs = "";
for ($i =0; $i <6; $i + +) {
$strs. = $srcstr [Mt_rand (0,35)];
}
Return Strtoupper ($strs);
}
$str =random (4);//The string that is generated by the dry machine
$width = 50;////The width of the captcha picture
$height = 25;//The height of the captcha picture
@header ("Content-typ E:image/png ");
$_session["code"] = $STR;
//echo $str;
$im =imagecreate ($width, $height);
//Background color
$back =imagecolorallocate ($im, 0xff,0xff,0xff);
//Blur 97xxoo point color
$pix =imagecolorallocate ($im, 187,230,247);
//Font Color
$font =imagecolorallocate ($im, 41,163,238);
//Plot blur point
Mt_srand ();
for ($i =0; $i <1000; $i + +)
{
Imagesetpixel ($im, Mt_rand (0, $width), Mt_rand (0, $height), $pix);
}
Imagestring ($im, 5, 7, 5, $STR, $font);
Imagerectangle ($im, 0,0, $width-1, $height-1, $font);
Imagepng ($im);
Imagedestroy ($im);
$_session["code"] = $STR;
?>
http://www.bkjia.com/PHPjc/630486.html www.bkjia.com true http://www.bkjia.com/PHPjc/630486.html techarticle PHP generated Verification code file is a learning PHP friends should know the technology oh, this can not only make your site safe to improve some, you can also note some machine registration and other problems Oh, the next ...