我想判断输入的验证码是否与图片上的验证码是否一致,$_session['code']是图片的验证码,number是(!
)我文本框输入的验证码,应该如何修改?
程序如下,个人猜想问题出在if($_post['number']==$_session['code'])这一句上,请大神帮忙修改
name=$x;
$this->pwd=$y;
}
function checkinput()
{
include(../conn/conn.php);
$sql=mysql_query(select * from tb_admin where name='.$this->name.',$conn);
$info=mysql_fetch_array($sql);
if($info==false)
{
echo ;
exit;
}
else
{
if($info[pwd]==$this->pwd)
{
if($_post['number']==$_session['code'])
{
header(location:index.php);}
else
{
echo ;
exit;}
}
else
{
echo ;
exit;
}
}
}
}
$obj=new chkinput(trim($_post[name]),trim($_post[pwd]));
$obj->checkinput();
?>
------解决方案--------------------
应该在最顶加一句
session_start(); // 开启session,否则$_session['code']会获取不到值。
------解决方案--------------------
$_post['number']==$_session['code']
输出变量是否有值不就知道?
------解决方案--------------------
没有开启session
var_dump($_session['code']);//输出看看是否有值
