2 qq 32867533 qq_32867533 于 2016.03.26 17:20 提问

我的php登录界面总是显示我账号密码错误。。。我找不出错误 恳求各位大神帮助
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body style="font-family:微软雅黑;text-align:center">
<h1>Welcome</h1>
<?php
if(!$_POST["user"])
{
    echo"<center>";
?>
<table border=1>
<form action="login.php" method="post">
<tr>
<td colspan="2" align="center">用户登录</td>
</tr>
<tr>
<td>输入用户名:</td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td>输入密码:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录"></td>
</tr>
</form>
</table>
<?php
}
else
{
    include"config.php";
    $user=$_POST["user"];
    $user=$_POST["pass"];
    $sql="SELECT COUNT(id) FROM $db_examsystem_user WHERE name='$user' AND pass='$pass'";
    $result=mysql_query($sql,$my_con);
    $num=mysql_fetch_row($result);
    if($num[0]==0)
    {
        echo"用户名或者密码错误,请检查!<p>";
        echo"单击<a href='login.php'>这里</a>重新登录<br/>";
        echo"单击<a href='regist.php'>这里</a>进行注册";
    }
    else
    {
        setcookie("user",$user);
        echo"登陆成功<p>";
        echo"单机<a href='index.php'>这里</a>进入系统";
    }
}
?>
</body>
</html>
</center>

2个回答

github_33295698
github_33295698   2016.03.26 19:55

不是$user=_POST['pass'];
( ̄∇ ̄)

xericoder
xericoder   2016.03.28 14:48

$user=$_POST["user"];
$user=$_POST["pass"];

太粗心了

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!