Hope all is well!
I am trying to code my login.php so that it redirects to consumerView.php for a member and admin.php for employee/admin. I have written the following php code but I keep getting redirected to consumerView.php even though the role of the login info is for an employee. Could someone provide any insight to get this working please? The SQL query works, I tested it in phpmyadmin. Disclaimer: I am new to php.
// SELECT query
$query1 = "SELECT u.id, u.email, u.pass password, r.name role
FROM users u INNER JOIN role r ON r.id = u.ro_fk
WHERE email = ? AND u.pass = ? ;";
if(r.name == 'member'){
header("Location: consumerView.php");}
else
{header("Location: admin.php");}
die();
} else {
//If the username/password doesn't matche a user in our database
// Display an error message and the login form
echo "Failed to login";
}
} else {
echo "failed to prepare the SQL";
}
}
?>