<?php
session_start();
error_reporting(E_ERROR);
$zh=$_POST['zh'];
$password=$_POST['密码'];
$user=$_POST['用户'] ;
if(!isset($user)){
echo "";
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' ";
$sql2="从教师中选择*,其中each_id ='$zh' 且密码='$password' ";
$sql3 ="从学生中选择*,其中stuno ='$zh'和密码='$password'";
mysqli_query($conn,"设置名称utf8");
switch($user ){
case 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'];
$_SESSION['admin_id']= $row['admin_id'];
echo "<script type='text/javascript'>"."location.href='".$url."'"."</script> ;";
}
else {
echo "";
echo "<script> History.go(-1);</script>";
}
Break;
情况 2:$结果=mysqli_query($sql2,$conn);
$result=mysqli_query($sql2,$conn)or die('查询不到');
$row = mysqli_fetch_array($result);
$count=$row[0];
if($count!=""){
$url="index_teacher.php";
$_SESSION['teacher_name']=$row['name'];
$_SESSION['teacher_id']=$row['teach_id'];
echo "<脚本类型='text/javascript'>"."location.href=' ".$url."'"."</script>";
}
else {
echo "<script>错误');</script>";
echo "<script> History.go(-1);</script>";
}
break;
情况 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 "";
echo "<script> History.go(-1);</script>";
}
break;
默认 :break;
}
mysqli_close($conn);
?>
后端断点打印是否能够拿到数据