在交换机案例中,学生和教师代码不能仅使用管理代码吗?

时间:2017-10-22 14:28:17

标签: php mysql arrays

<?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){             案例&#39;管理&#39;:                 标题(&#34;位置:admindashboard.php&#34;);                 打破;             案例&#39;教师&#39;:                 标题(&#34;位置:admindashboard.php&#34;);                 打破;             案例&#39;学生&#39;:                 标题(&#34;位置:Studentdashboard.php&#34;);                 echo $ type;                 回声(&#34; aaaaa&#34;);                 打破;         }     }

1 个答案:

答案 0 :(得分:0)

“if($ type ='administration'){”不正确“elseif($ type ='faculty'){”也错了:

if ($type=='administration') { 
...
 elseif ($type=='faculty') {

就是这样。请参阅每个陈述中'='的数量。