想用php做一個能生成驗證碼的登陸界面,可是查過很多的資料,依然沒有解決問題,總是不能顯示圖片,系統已經有安裝了gd-2.0.28-4,請高手指點如何才能正確顯示圖片呢?
<?php
session_start();
srand((double)microtime()*1000000); //验证用户输入是否和验证码一致
if(isset($HTTP_POST_VARS['authinput']))
{
if(strcmp($HTTP_POST_VARS['authnum'],$HTTP_POST_VARS['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>
<?php
session_start();
srand((double)microtime()*1000000); //验证用户输入是否和验证码一致
if(isset($HTTP_POST_VARS['authinput']))
{
if(strcmp($HTTP_POST_VARS['authnum'],$HTTP_POST_VARS['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>
解决方案 »
- PHP xajax 提交时出现the xml response that was returned from the server is invalid 错误
- php如何读取数据库信息
- 用phpmailer老出错,在线急等
- Fatal error: Allowed memory size of 587202560 bytes exhausted (tried to allocate 493123764 bytes) in
- 子框架获得父框架url
- 谁帮我分析下这个是正则表达式吗?
- 变量怎么转换成数组里面的内容
- 在PHP界面中进行邮箱登录的问题!
- 纠结中,请指教,抓取的问题
- 请问这种格式的数据如何用PHP读出
- 如何使网页不能被复制、粘贴、保存,像起点的VIP章节那样?
- 关于上传的问题,怎么先判断文件是否存在再上传??
把验证码放在这儿不行,要存放在cookie/session中,不然没有意义了
另外同楼上的楼上,验证码放在$_SESSION里面,不要放在hidden域发送.