 <p>Try something like this maybe (This is assuming that on login and register you set a $_SESSION variable containing their user id or some other identifier):</p> <pre><code>if(empty($_SESSION['user'])) { // If they are not, redirect them to the login page. header("Location: login.php"); die("Redirecting to login.php"); } else { include_once("databaseConnection.php"); $checkAdmin = "SELECT user_role FROM users WHERE id = '".$_SESSION['user_id']."';"; $result = mysqli_query($conn, $checkAdmin); $user_role = mysqli_fetch_assoc($result); if ($user_role == "reader") { // User is only a reader, redirecting them to the home page header("Location: /"); die("You're only a reader and you're not allowed here, redirecting you to the home page!"); } elseif ($user_role == "editor") { // User is only an editor, redirecting them to the home page header("Location: /"); die("You're only an editor and you're not allowed here, redirecting you to the home page!"); } elseif ($user_role == "editor") { // User is an admin, allowing them through } else { //Error identifying user's role header("Location: /"); die("Some kind of error occured, show this to the site owner: (User role identification error)"); } } </code></pre>