根据用户帐户类型或使用用户名和密码重定向页面

问题描述 投票:0回答:1

我一直在研究这个PHP代码,但我无法使用账户类型Dean,Registrar,Incharge of Accounts和Cashier将它们连接到他们的特定页面。

我尝试了什么:

<?php include("header.php");
    include("banner.php") ?>
    <?php
        if (isset($_POST['btnlogin'])) {
            $uname = trim($_POST['uname']);
            $upass = trim($_POST['pass']);

            $h_upass = sha1($upass);
            if ($uname == '' OR $upass == '') {
        }
    ?>
?>   <script type="text/javascript">
        alert("Invalid Username and Password!");
    </script>
<?php    
    } else {
        $user = new User();
        $res = $user::AuthenticateUser($uname, $h_upass); 
?>
javascript php
1个回答
-1
投票

你尝试过使用标题功能吗?如果你可以使用中间件将用户重定向到特定的文件,那将是很好的做法。

<?php include("header.php");
include("banner.php") ?>
<?php
if (isset($_POST['btnlogin'])) {

    $uname = trim($_POST['uname']);
    $upass = trim($_POST['pass']);

    $h_upass = sha1($upass);
    if ($uname == '' OR $upass == '') {


}
?>
?>    <script type="text/javascript">
                alert("Invalid Username and Password!");
                </script>
            <?php

    } else {
        $user = new User();
        $res = $user::AuthenticateUser($uname, $h_upass);
        if($res)
         {  

            if($user->role == "Dean")
            {
             header('Location: Dean.php');
            }else if($user->role == "Dean")
           {
            header('Location: Registrar.php');
             }

         }

       }

?>
© www.soinside.com 2019 - 2024. All rights reserved.