I'm currently in a school-project and we are doing a site where there are three different types of roles.
In our user-table we have an attribute named "role". This role has a table with 3 different values, 1, 2 and 3.
1 (Admin) 2 (Adminuser) 3 (user).
What I want is: When someone is logging in, the code wants to look for what value in role this user has and then redirect this user to "admin.php" (if the value is 1), "adminuser.php" (if the value is 2) or "user.php" if the value is 3. This is the current code, and it works so that you can login, but you get sent to the same page regardless.
if(isset($_POST['email']))
{
$query = <<<END
SELECT email, password, userID, FROM user
WHERE email = '{$_POST['email']}'
AND password = '{$_POST['password']}'
END;
$res = $mysqli->query($query);
if ($res->num_rows > 0)
{
$row = $res->fetch_object();
$_SESSION["email"] = $row->email;
$_SESSION["userID"] = $row->id;
header("Location:admin.php");
}
else
{
echo "Fel email eller lösenord.";
}
}