附加码为什么不会显示

freescy2002 freescy2002 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我按照下面的提示,不知为什么不会显示附加码,高手看一下,运行authpage.php 发现是图片的小叉叉啊。

<?
/*
* Filename: authpage.php
* Date: 2003-7-13
* Version: 1.3.2
*/
session_start();
//验证用户输入是否和验证码一致
if (isset($_POST['authinput']))
{
if ($_SESSION['auth'] == $_POST['authinput'])
{
echo "验证成功!";
exit;
} else echo "验证失败!";
}
?>
<form action=authpage.php method=post>
<table><tr><td>请输入验证码:<input type=text name=authinput style="width: 80px"><img src=authimg.php></td></tr>
<tr><td><input type=submit name="验证" value="提交验证码">
</td></tr>
</table>
</form>
===============================================================================
<?php
/*
* Filename: authimg.php
* Date: 2003-7-13
* Version: 1.3.2
*/

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

while(($authnum=rand()%10000)<1000);//生成四位随机整数验证码
$_SESSION['auth']=$authnum;

//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate(50,20);
$black = ImageColorAllocate($im, 200,10,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 230,230,230);
imagefill($im,68,30,$gray);

//将四位整数验证码绘入图片
//位置交错
for ($i = 0; $i < strlen($authnum); $i++) {
if ($i % 2 == 0) $top = 1;
else $top = 5;
imagestring($im, 5, 10*$i+6, $top, substr($authnum,$i,1), $black);
}

for ($i = 0; $i < 150;$i++) //加入干扰象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $black);
}

ImagePNG($im);
ImageDestroy($im);

?>
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
freescy2002
基础编程 21,889 成员 140,329 内容