一、用户登录界面
学生综合评分系统
|                                                                                                  用户名 | |
|                                                                                                  密 码 | |
|     |
?>
二、后台处理
<?php session_start(); header("Content-Type:text/html;charset=gbk"); //isset检测变量是否被设置,最好使用上,可以不使用他的。 //学生登录 if(isset($_POST["login_student"]) && $_POST["login_student"] =="学生登录"){ $user = $_POST["username"]; $psw = $_POST["password"]; if($user == "" || $psw == ""){ //alert是警告的意思。这句的主要做用就是弹出警告,返回上一页。 echo ""; //弹出提示框返回上一页 }else if($row[4]!=$psw){ echo ""; //弹出提示框返回上一页 }else{ $_SESSION["Student_Name"]=$row[1];//页面显示登录人的姓名。 $_SESSION["username"]=$row[3]; $_SESSION["Student_ID"]=$row[0]; $_SESSION["Student_Class"]=$row[2]; if($row[5]=="A"){ header("Location: http://192.168.116.128/school/studentA/exam/exam.php");//跳转到这个界面。 }else if($row[5]=="B"){ header("Location: http://192.168.116.128/school/studentB/exam/exam.php");//跳转到这个界面。 }else if($row[5]=="C"){ header("Location: http://192.168.116.128/school/studentC/exam/exam.php");//跳转到这个界面。 } } } } } if(isset($_POST["login_teacher"]) && $_POST["login_teacher"] =="教师登录"){ $user = $_POST["username"]; $psw = $_POST["password"]; if($user == "" || $psw == ""){ //alert是警告的意思。这句的主要做用就是弹出警告,返回上一页。 echo ""; //弹出提示框返回上一 }else{ $con=mysql_connect("localhost","root","9277"); mysql_select_db("School",$con); mysql_query("set names 'gbk'"); $result=mysql_query("select * from Teacher where Username ='$user' ");//mysql_query 查询数据库的函数 while($row=mysql_fetch_array($result)){ if($row[2]==""){ echo ""; //弹出提示框返回上一页 }else if($row[3]!=$psw){ echo ""; //弹出提示框返回上一页 }else{ $_SESSION["teacher_Name"]=$row[0];//页面显示登录教师的姓名。 $_SESSION["teacher_Class"]=$row[4]; header("Location: http://192.168.116.128/school/teacher/exam/exam.php"); } } } } ?>