PHP Generate captcha Code _php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.