php-Generate Verification Code PHP verification code Download PHP email Verification Code PHP website verification

Source: Internet
Author: User
  /*** Created by Phpstorm.* User:* DATE:2016/4/20* time:20:07 */session_start ();//draw a background map$image=imagecreatetruecolor ( -, -);$bgcolor=imagecolorallocate ($image,255,255,255);Imagefill ($image,0,0,$bgcolor);/*//generate four-bit random numbersFor ($i =0; $i <4; $i + +) {$f$f$f      //where the numbers are displayed$x = ($i *100/4) +rand (5,9);$y =rand (5,10);imagestring ($image, $fonsize, $x, $y, $fontcontent, $foncolor);   }*/$captch _code='';//generate digital letter mixed verification Code for($i=0;$i<4;$i++) {$fonsize=6;$fontcolor=imagecolorallocate ($image,rand (0, -),rand (0, -),rand (0, -));$data="abcdefghjklmnpqrstuvwxy13456789";$fontcontent=substr ($data,rand (0,strlen ($data)),1);$captch _code.=$fontcontent;//location of verification code$x=($i* -/4) +rand (5,Ten);$y=rand (5,Ten);//imagestring ($image,$fonsize,$x,$y,$fontcontent,$fontcolor);}$_session[' Authcode ']=$captch _code;//adding interference elements:Point for($i=0;$i< $;$i++) {$pointcolor=imagecolorallocate ($image,rand ( -, $),rand ( -, $),rand ( -, $));Imagesetpixel ($image,rand (1, About),rand (1, About),$pointcolor);}//Add interference element: line for($i=0;$i<3;$i++) {$linecolor=imagecolorallocate ($image,rand ( the, -),rand ( the, -),rand ( the, -));Imageline ($image,rand (1, About),rand (1, in),rand (1, About),rand (1, in),$linecolor);}Header (' Content-type:image/png ');Imagepng ($image);Imagedestroy ($image);?>

The above describes the php-generated verification code, including the verification Code, PHP content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.