动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 发布一个图形数字验证代码

作者来源: 
阅读 数 668 人次 , 2006-3-29 4:11:00 


以下代码本人调试全部通过。运行authpage.php。

<?

/*

* filename: authpage.php

*/

srand((double)microtime()*1000000);

//验证用户输入是否和验证码一致

if(isset($_post['authinput']))

{


if(strcmp($_post['authnum'],$_post['authinput'])==0)

echo "验证成功!";

else

echo "验证失败!";

}

//生成新的四位整数验证码

while(($authnum=rand()%10000)<1000);

?>

<form action=authpage.php method=post>

<table>

请输入验证码:<input type=text name=authinput style="width: 80px"><br>

<input type=submit name="验证" value="提交验证码">

<input type=hidden name=authnum value=<? echo $authnum; ?>>

<img src=authimg.php?authnum=<? echo $authnum; ?>>

</table>

</form>

-------------------------------------------------------------------------------------------------------------

<?
/*

* filename: authimg.php

*/
//生成验证码图片
header("content-type: image/png");

srand((double)microtime()*1000000);

$im = imagecreate(58,28);

$black = imagecolorallocate($im, 0,0,0);

$white = imagecolorallocate($im, 255,255,255);

$gray = imagecolorallocate($im, 200,200,200);

imagefill($im,68,30,$gray);

//将四位整数验证码绘入图片

imagestring($im, 5, 10, 8, $http_get_vars['authnum'], $white);

for($i=0;$i<50;$i++) //加入干扰象素

{

imagesetpixel($im, rand()%70 , rand()%30 , $gray);

}

imagepng($im);

imagedestroy($im);

?>
__________________

java->struts

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:如何正确统计中文字数
· 下一篇:如何将gbk编码转成utf8格式
· 用php和imagemagick来处理图片文件的上传和缩放处理
· 一个好用的UBB类
· PHP下MAIL的另一解决方案
· 一个对数据库进行操作的程序
· MySQL以速度为目标


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077