prepare('SELECT * FROM accounts WHERE id = ?'); $stmt->execute([ $_SESSION['account_id'] ]); $account = $stmt->fetch(PDO::FETCH_ASSOC); if (!$account || $account['role'] != 'Admin') { header('Location: ' . url('../index.php')); exit; } // Page is set to home (home.php) by default, so when the visitor visits that will be the page they see. $page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : 'dashboard'; if (isset($_GET['page']) && $_GET['page'] == 'logout') { session_destroy(); header('Location: ' . url('../index.php')); exit; } // Output error variable $error = ''; // Include the requested page include $page . '.php'; ?>