Chinaunix首页 | 论坛 | 博客
  • 博客访问: 256984
  • 博文数量: 76
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 745
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-28 16:04
文章分类

全部博文(76)

文章存档

2013年(2)

2010年(21)

2009年(53)

我的朋友

分类:

2009-10-29 16:16:15

AuthImg.php[CODE:]

session_start();
/* 
 *   Filename: authimg.php 
 *   Author:   hutuworm 
 *   Date:     2003-04-28 
 *   @Copyleft hutuworm.org 
 */ 
Header("Content-type: image/PNG"
);  
srand((double)microtime()*1000000
); 
$im = imagecreate(62,20
); 
$black = ImageColorAllocate($im, 0,0,0
); 
$white = ImageColorAllocate($im, 255,255,255
); 
$gray = ImageColorAllocate($im, 200,200,200
); 
imagefill($im,0,0,$gray
); 
while((
$authnum=rand()%100000)<10000
);
imagestring($im, 5, 10, 3, $authnum, $black
); 
for(
$i=0;$i<200;$i++)
{ 
    
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255
));
    
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor
); 
} 
$_SESSION['authnum']=$authnum
;
ImagePNG($im
); 
ImageDestroy($im
); 
?>
使用方法:[CODE:]
0>
认证页:[CODE:]
if($_SESSION['authnum']==$_POST["VerifyCode"]){ 
    $link -> Inf_right("正确!");
}else{ 
    
$link -> Inf_wrong("验证码输入错误!"
);
}

很快很方便~!
阅读(433) | 评论(0) | 转发(0) |
0

上一篇:PHP 强制类型转换

下一篇:PHP邮件发送函数

给主人留下些什么吧!~~