模拟管理系统出现以下问题:
数据库名:empman 里面有两张表:admin 和 emp 其中admin中字段:id name password
现有代码:
login.php文件:
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和密码后就不正常跳转了 ,不知问题所在
Stellungnahme:Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn