欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP登录界面问题请教

程序员文章站 2024-02-10 18:09:40
...
模拟管理系统出现以下问题:
数据库名:empman 里面有两张表:admin 和 emp 其中admin中字段:id name password

现有代码:

login.php文件:






用户id:
密&nbsp码:




if(!empty($_GET['errno']))
{
$errno=$_GET['errno'];
if($errno==1)
{
echo "
你的用户名或密码错误!";
}
}
?>

loginProcess.php文件:
//用户id
$id=$_POST['id'];

//用户密码
$password=$_POST['pwd'];

//连接数据库
$conn=mysql_connect("localhost","root","root");
if(!$conn)
{
die("连接失败".mysql_errno());
}
mysql_query("set name utf8",$conn) or die(mysql_errno());

mysql_select_db("empman",$conn) or die(mysql_errno());

$sql="select password from admin where id=$id";

$res=mysql_query($sql,$conn);

if($row=mysql_fetch_assoc($res))
{
if($row['password']== md5($password))
{
header("Location:empManage.php");
exit();
}
}
header("Location:login.php?errno=1");
exit();

mysql_free_result($res);
mysql_close($conn);
}
现象:在login页面中输入正确id和密码后什么都不显示 直接跳到loginProcess.php页面了,找不到问题所在,请大家指教。


回复讨论(解决方案)

表单提交后是会跳转的,如果不想跳转请使用ajax

如果不连数据库是可以正常跳转的,连入数据库后验证id和密码后就不正常跳转了 ,不知问题所在