<?php
include("dbh.php");
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$username = strtoupper($_POST['username']);
$password = $_POST['password'];
echo $_POST['category'];
$type = $_POST['category'];
$sql = "SELECT * FROM user WHERE upper(username) = '$username' and password = '$password' and type ='$type'";
$result = mysqli_query($db, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$active = (isset($row['active']));
$count = mysqli_num_rows($result);
// If result matched $username and $password, table row must be 1 row
/* if($count == 1) {
// session_register("username");
$_SESSION["login_user"] = $username;
setcookie("username1", $username, time()+3600, "/","", 0);
仅切换管理案例不起作用,而不是学生和教职员工//
开关 ($type) { 案例"管理": header("location: admindashboard.php"); 破; 案例"教师": header("location: admindashboard.php"); 破; 案例"学生": header("location: Studentdashboard.php"); 回声$type; 回声("aaaaa"); 破; } }
不正确 "elseif ($type='faculty') {" 也是错误的:
if ($type=='administration') {
...
elseif ($type=='faculty') {
就是这样。请参阅每个语句中 '= 的数量。