|
圖形數(shù)字驗(yàn)證代碼Code: <?
/*
* Filename: authpage.php
*/
srand((double)microtime()*1000000);
//驗(yàn)證用戶輸入是否和驗(yàn)證碼一致
if(isset($_POST['authinput']))
{
if(strcmp($_POST['authnum'],$_POST['authinput'])==0)
echo "驗(yàn)證成功!";
else
echo "驗(yàn)證失??!";
}
//生成新的四位整數(shù)驗(yàn)證碼
while(($authnum=rand()%10000)<1000);
?>
<form action=authpage.php method=post>
<table>
請輸入驗(yàn)證碼:<input type=text name=authinput style="width: 80px"><br>
<input type=submit name="驗(yàn)證" value="提交驗(yàn)證碼">
<input type=hidden name=authnum value=<? echo $authnum; ?>>
<img src=authimg.php?authnum=<? echo $authnum; ?>>
</table>
</form>
-------------------------------------------------------------------------------------------------------------
<?
/*
* Filename: authimg.php
*/
//生成驗(yàn)證碼圖片
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);
//將四位整數(shù)驗(yàn)證碼繪入圖片
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);
主站蜘蛛池模板: 岳普湖县| 扶余县| 永兴县| 聂荣县| 道孚县| 鹿邑县| 南阳市| 喜德县| 仙桃市| 防城港市| 海口市| 仙游县| 渝中区| 通州区| 阿拉善盟| 遵化市| 平潭县| 临湘市| 甘肃省| 故城县| 牙克石市| 仙游县| 湟源县| 淳化县| 黔东| 乌恰县| 钟祥市| 那坡县| 邯郸市| 社旗县| 大渡口区| 庆元县| 平顶山市| 焦作市| 德令哈市| 夏邑县| 双城市| 青阳县| 东至县| 长宁区| 大连市|