我一直在研究这个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);
?>
你尝试过使用标题功能吗?如果你可以使用中间件将用户重定向到特定的文件,那将是很好的做法。
<?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');
}
}
}
?>