33 lines
844 B
PHP
33 lines
844 B
PHP
<?php
|
|
require_once __DIR__ . '/../includes/header.php';
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: /login.php');
|
|
exit;
|
|
}
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT role FROM users WHERE id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$user = $stmt->fetch();
|
|
|
|
if (!$user || $user['role'] !== 'admin') {
|
|
// Redirect to the dashboard or show an error message
|
|
header('Location: /dashboard.php?error=unauthorized');
|
|
exit;
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="container">
|
|
<h1 class="mt-5">Admin Panel</h1>
|
|
<p>Welcome to the admin panel. Here you can manage users and services.</p>
|
|
<ul>
|
|
<li><a href="users.php">Manage Users</a></li>
|
|
<li><a href="services.php">Manage Services</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<?php require_once __DIR__ . '/../includes/footer.php'; ?>
|