21 lines
435 B
PHP
21 lines
435 B
PHP
<?php
|
|
session_start();
|
|
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
function is_admin() {
|
|
return isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
|
|
}
|
|
|
|
function check_admin() {
|
|
if (!is_admin()) {
|
|
// You can customize this part, e.g., show an error message or redirect.
|
|
die('You are not authorized to access this page.');
|
|
}
|
|
}
|
|
?>
|