FocuZst Posted August 7, 2015 Share Posted August 7, 2015 (edited) I'm trying to restrict users from accessing a page if their rank isn't manager or admin. I made a variable called $rank which is the rank that is fetched from the user's table in my database. When I echo the rank on the page, the rank does equal to manager or admin but it redirects me to the index page because it somehow doesn't equal manager or admin. When I try using this code: if(!isset($_SESSION['userID'])) { header("Location: index.php");} else if ($rank == "manager" OR $rank == "admin") { } else { header("Location: index.php");} it does work but I feel like that's the wrong way of doing it. This is the code that I'm using now and isn't working: $tUsers_Select = "SELECT users.rank, ranks.rank_name FROM users LEFT JOIN ranks ON users.rank = ranks.rank_name WHERE user_id = ".$_SESSION['userID'];$tUsers_Select_Query = mysqli_query($dbConnect, $tUsers_Select);$fetch = mysqli_fetch_array($tUsers_Select_Query);$rank = $fetch['rank'];if(!isset($_SESSION['userID'])) {header("Location: index.php");} else if ($rank !== "manager" OR $rank !== "admin") {header("Location: index.php");} Hopefully you understood. Please comment if you have any questions. Edited August 7, 2015 by FocuZst Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2015 Share Posted August 7, 2015 else if ($rank !== "manager" OR $rank !== "admin")"If rank does not equal manager or admin". When is rank going to equal both manager and admin at the same time? It's always going to either not be manager, not be admin, or both. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now