PHP怎么做图片验证码啊? 我就想知道怎么能做出来,只要能和PHP的登录界面放在一起就行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 验证码生成:<?php$num="";for($i=0;$i<4;$i++){ $num.=rand(0,9);}Session_start();$_SESSION["Checknum"]=$num;Header("Content-typt:image/PNG");$im=imagecreate(60,20);$black=ImageColorAllocate($im,0,0,0);$gray=ImageColorAllocate($im,200,200,200);imagefill($im,0,0,$gray);$style=array($black,$black,$black,$black,$black,$gray,$gray,$gray,$gray,$gray);imagesetstyle($im,$style);$y1=rand(0,20);$y2=rand(0,20);$y3=rand(0,20);$y4=rand(0,20);imageline($im,0,$y1,60,$y3,IMG_COLOR_STYLED);imageline($im,0,$y2,60,$y4,IMG_COLOR_STYLED);for($i=0;$i<80;$i++){ imagesetpixel($im,rand(0,60),rand(0,20),$black);}$setx=rand(8,15);for($i=0;$i<4;$i++){ $strpos=rand(1,6); imagestring($im,5,$strx,$strpos,substr($num,$i,1),$black); $strx+=rand(12,18);}ImagePNG($im);ImageDestroy($im);?>输入验证码:<html><head><title>test</title></head><body><form action="t3.php" method="post"><img src="t1.php"><a href="t2.php">换一个</a><input type="text" name="password"><br><input type="submit" value="确定"></form></body></html>结果:<?phpSession_start();$pass1=$_POST["password"];$pass2=$_SESSION["Checknum"];if($pass1==$pass2){ echo "验证通过";}else{ echo "验证失败"; }?> 要开启GD库支持你可以phpinfo();察看是否开启了 看http://blog.csdn.net/luojxun/archive/2008/09/27/2979694.aspx 关于通过采集新闻的程序 怎样定时获取新闻信息 ecshop相关 phpMyAdmin一打开就乱码 关于如何php给键值对数组增加一个新的键值对? 简单的题目,看看你能不能做出来。 关于SQLite 耗时十月,生了个孩子(作品),筵宴,散所有分 文件操作问题 php如何支持flash 数据库里提出的数据,在表格内不能自动换行 php可以同时联接两个sql server 吗? 大家 知道 div可以嵌套 那么 我这样嵌可不可以呢 ?
<?php
$num="";
for($i=0;$i<4;$i++){
$num.=rand(0,9);
}
Session_start();
$_SESSION["Checknum"]=$num;
Header("Content-typt:image/PNG");
$im=imagecreate(60,20);
$black=ImageColorAllocate($im,0,0,0);
$gray=ImageColorAllocate($im,200,200,200);
imagefill($im,0,0,$gray);
$style=array($black,$black,$black,$black,$black,$gray,$gray,$gray,$gray,$gray);
imagesetstyle($im,$style);
$y1=rand(0,20);
$y2=rand(0,20);
$y3=rand(0,20);
$y4=rand(0,20);
imageline($im,0,$y1,60,$y3,IMG_COLOR_STYLED);
imageline($im,0,$y2,60,$y4,IMG_COLOR_STYLED);
for($i=0;$i<80;$i++){
imagesetpixel($im,rand(0,60),rand(0,20),$black);
}
$setx=rand(8,15);
for($i=0;$i<4;$i++){
$strpos=rand(1,6);
imagestring($im,5,$strx,$strpos,substr($num,$i,1),$black);
$strx+=rand(12,18);
}
ImagePNG($im);
ImageDestroy($im);
?>输入验证码:
<html>
<head>
<title>test</title>
</head>
<body>
<form action="t3.php" method="post">
<img src="t1.php">
<a href="t2.php">换一个</a>
<input type="text" name="password"><br>
<input type="submit" value="确定">
</form>
</body>
</html>结果:
<?php
Session_start();
$pass1=$_POST["password"];
$pass2=$_SESSION["Checknum"];
if($pass1==$pass2){
echo "验证通过";
}else{
echo "验证失败";
}
?>