我需要進行多用戶登錄,因此管理員將登錄到 admin.php,而店員將被重定向到 clerk.php。但我有一個問題。到目前為止,我已經對其進行了編碼,它可以讓我將職員重定向到 clerk.php。但是我的管理員登錄只會讓我回到 index.php。Github 如果你想要更好的主意。https://github.com/markRichie/MSS這是我下面的代碼。函數.php: if(mysqli_num_rows($result) > 0) { while($row =mysqli_fetch_assoc($result)) { if($row["Role"] == "admin") { $_SESSION['User'] = $row["username"]; $_Session['Role'] = $row["Role"]; header('Location: admin.php'); } else { $_SESSION['User'] = $row["username"]; $_Session['Role'] = $row["Role"]; header('Location: clerk.php'); } } } else { header('Location: index.php'); }}?>管理員.php:<?phpsession_start();if(isset($_SESSION['Role'])){ if($_SESSION['Role'] != 'admin') { header('Location: clerk.php'); }}else{ header('Location: index.php');}我的桌子:CREATE TABLE `multilogin` ( `ID` int(11) NOT NULL, `username` varchar(30) NOT NULL, `password` varchar(30) NOT NULL, `Role` varchar(20) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
使用 PHP/MYSQLI 進行多重登錄
幕布斯6054654
2022-06-17 17:17:31
