数据库已经有注册的数据,但是在首页登录界面一直提示不存在此用户,这是判断的页面,请帮忙看一下

以下是php代码
<?php
include("conn/conn.php");
$username=@$_POST['name'];
$userpwd=@md5($_POST['pwd']);
$yz=@$_POST['yz'];
$num=@$_POST['num'];
if(strval($yz)!=strval($num)){
echo "<script>alert('验证码输入错误!');history.go(-1);</script>";
exit;
}
class chkinput{
var $name;
var $pwd;

function chkinput($x,$y){
$this->name=$x;
$this->pwd=$y;
}

function checkinput(){
include("conn/conn.php");
$sql=mysql_query("select * from tb_user where name='".$this->name."'",$conn);
$info=mysql_fetch_array($sql);
if($info==false){
echo "<script language='javascript'>alert('不存在此用户!');history.back();</script>";
exit;
}
else{
if($info[dongjie]==1){
echo "<script language='javascript'>alert('该用户已经被冻结!');history.back();</script>";
exit;
}

if($info[pwd]==$this->pwd)
{
session_start();
$_SESSION[username]=$info[name];
session_register("producelist");
$producelist="";
session_register("quatity");
$quatity="";
header("location:index.php");
exit;
}
else {
echo "<script language='javascript'>alert('密码输入错误!');history.back();</script>";
exit;
}
}
}
}

$obj=new chkinput(trim($username),trim($userpwd));
$obj->checkinput();
?>
登录时,尽管数据库有的用户名,也提示用户名不存在。然后吧sql进行查询"select * from tb_user where name='".$this->name."'"没查询到值。请问这是怎么回事,我是php新手,不太懂代码,求指教
$info=mysql_fetch_array($sql);
if($info==false){
echo "<script language='javascript'>alert('不存在此用户!');history.back();</script>";
exit;
}

估计

    可能是sql语句组装有问题:select * from tb_user where name='".$this->name."'",可以在程序中输出这个结果,直接在查询分析器中运行试试;

    数据库中的name前后有空格,或是$this->name前后有空格,入库前应消除前后空格,查询前也应过滤空格

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网