Home >Backend Development >PHP Tutorial > PHP认证码解决方案

PHP认证码解决方案

WBOY
WBOYOriginal
2016-06-13 13:48:24940browse

PHP认证码
谁给我写个认证码,如果实现通过现金谢~~~现金200元人民币~~~QQ:357816807

------解决方案--------------------
写的太早了,你自己调试下。

PHP code
<?php /*
*       Filename:   authimg.php
*       Author:       唯她
*       Date:           2003年6月3日
*       @Copyleft   www.vitalstudio.cn
*/
session_start();
srand((double)microtime()*1000000);
while(($authnum=rand()%10000) < 1000);//生成四位随机整数验证码
$_SESSION['auth']=$authnum;
//生成验证码图片
Header("Content-type:   image/png");
$im   =   imagecreate(45,16);
$black   =   ImageColorAllocate($im,   200,10,0);
$white   =   ImageColorAllocate($im,   255,255,255);
$gray   =   ImageColorAllocate($im,   230,230,230);   //将这两行提前至   $im   ..下面
imagefill($im,68,30,$gray);
//将四位整数验证码绘入图片
//位置交错
for   ($i   =   0;   $i   <   strlen($authnum);   $i++)   {
if   ($i%2   ==   0)   $top   =   0;
else   $top   =   2;
imagestring($im,   5,   10*$i+3,   $top,   substr($authnum,$i,1),   $black);
}
for($i=0;$i<250;$i++)       //加入干扰象素
{
imagesetpixel($im,   rand()%70   ,   rand()%30   ,   $black);
}
ImagePNG($im);
ImageDestroy($im);
?> <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn