I need to do a multi userlogin, so the admin will be logged into admin.php and the clerk will be redirected into clerk.php.
But I am having a issue. I have coded it so far and it lets me redirect clerk to clerk.php. But my admin login just returns me back to the index.php. Github if you want a better idea. https://github.com/markRichie/MSS
This is my code below.
Functions.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');
}
}
?>
Admin.php:
<?php
session_start();
if(isset($_SESSION['Role']))
{
if($_SESSION['Role'] != 'admin')
{
header('Location: clerk.php');
}
}
else
{
header('Location: index.php');
}
And my table:
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;