问题描述
- 我的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>
解决方案
不是$user=_POST['pass'];
( ̄? ̄)
解决方案二:
$user=$_POST["user"];
$user=$_POST["pass"];
太粗心了
时间: 2024-09-18 21:35:43