国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

How to write in PHP to log in to different pages with different usernames and passwords
TimeLimit
TimeLimit 2018-06-17 13:51:17
0
1
1436

As a novice, I originally imagined that when adding a user, I would select the value of value, enter the username and password when logging in, and at the same time determine whether the value of the selected value is 0 or 1, and enter different pages

QQ截圖20180617134224.jpg

The value is saved in the database as class

QQ截圖20180617134417.jpg

But I don’t know how to take a certain person’s class value out of the database. Judgment, I don’t know how to improve the code. Please give me some advice.

<meta charset="utf-8">
<?php 
    
    if(isset($_POST["submit"]) && $_POST["submit"] == "登陸") 
    { 
        $user = $_POST["username"]; 
        $psw = $_POST["password"]; 
        
        $Dclass = $_POST["class"]; 
        if($user == "" || $psw == "") 
        { 
            echo "<script>alert('請輸入用戶名或密碼!'); history.go(-1);</script>"; 
        } 
        else 
        { 
            mysql_connect("localhost","root","root"); 
            mysql_select_db("hospital"); 
            mysql_query("set names utf-8"); 
            $sql = "select username,password,ID,class from user where username = '$_POST[username]'and password = '$_POST[password]'"; 
            $result = mysql_query($sql); 
            $num = mysql_num_rows($result); 
            if($num) 
            { 
                $row = mysql_fetch_array($result);  //將數(shù)據(jù)以索引方式儲存在數(shù)組中 
                echo $row[0]; 
                
            } 
            else 
            { 
                echo "<script>alert('用戶名或密碼不正確!');history.go(-1);</script>"; 
            } 
        } 
    } 
    else 
    {       mysql_connect("localhost","root","root"); 
            mysql_select_db("hospital"); 
            mysql_query("set names utf-8"); 
            $sql = " Dclass = '$_POST[class]'"; 
            $result = mysql_query($sql); 
                  

            if($result=="0"){
          //醫(yī)生的頁面
          echo"<script>alert('登錄成功哦,您是醫(yī)生!');location.href='../hospitalmain.html'</script>";
                                     }
        else{
          //管理員的頁面
          echo"<script>alert('登錄成功哦,您是管理員!');location.href='../adminmain.html'</script>";
            }

        /*echo "<script>alert('登錄成功!歡迎回來!');window.location.href='../costmain.html'</script>";*/
   }

?>


TimeLimit
TimeLimit

reply all(1)
靈魂獨行

It is recommended to use ajax to verify the data. You can obtain the data in the class through js and make logical judgments before jumping.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template