<?php
session_start();
error_reporting(E_ERROR);
$zh=$_POST['zh'];
$password=$_POST['password'];
$user=$_POST['user'];
if(!isset($user)) {
echo "<script> Alert('请选择用户类型');</script>";
echo "<script> History.go(-1);</script>";
}
$conn=mysqli_connect("localhost","8admin","8admin")or die('连接数据库失败');
$db=mysqli_select_db($conn,"8_com");
$sql1 ="SELECT*FROM admin WHERE admin_id ='$zh' AND password='$password' ";
$sql2="select * from teacher where teaching_id ='$zh' and password='$password' ";
$sql3="select * from student where stuno ='$zh' and password='$password' ";
mysqli_query($conn,"set name utf8");
switch($user){
Fall 1 :$result=mysqli_query($conn,$sql)or die('查询不到');
$row = mysqli_fetch_array($conn,$result);
$count=$row[0];
if($count!=""){
$url="index_admin.php";
$_SESSION['admin_name']=$row['name'];
"."location.href='".$url."'"."</script>";
}
else {
echo "<script> warning('账户或密码错误'); </script>";
echo "<script> History.go(-1);</script>";
}
break;
Fall 2:$result=mysqli_query($sql2, $conn);
$result=mysqli_query($sql2,$conn)or die('查询不到');
$row = mysqli_fetch_array($result);
$count=$row[0];
if($count!=""){
$_SESSION['teacher_name']=$row['name'];
$_SESSION['teacher_id']= $row['teach_id'];
echo "<script type='text/javascript'>"."location.href='".$url."'"."</script>";
}
else {
echo "<script> Alert('账户或密码错误');</script>";
echo "<script> History.go(-1);</ script>";
}
break;
case 3:$result=mysqli_query($sql3,$conn);
$result=mysqli_query($sql3,$conn)or die('查询不到');
$row = mysqli_fetch_array($result);
$count=$row[0];
if($count!=""){
$url="index_stu.php";
$_SESSION[ 'stu_name']=$row['name'];
$_SESSION['stu_id']=$row['stuno'];
echo "<script type='text/javascript'>"." location.href='".$url."'"."</script>";
}
else {
echo "<script> Alert('账户或密码错误');</ script>";
echo "<script> History.go(-1);</script>";
}
default : Pause;
}
mysqli_close($conn);
?>
后端断点打印是否能够拿到数据