diff --git a/admin.php b/admin.php index 8ef66c5..9f2684a 100644 --- a/admin.php +++ b/admin.php @@ -5,17 +5,18 @@ require_once __DIR__ . '/db/config.php'; $pdo = db(); if (!isset($_SESSION['user_id'])) { - header('Location: index.php'); + header('Location: /admin_login.php'); exit; } -$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?"); +$stmt = $pdo->prepare("SELECT * FROM admin_users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); -$user = $stmt->fetch(); +$admin = $stmt->fetch(); +$user = $admin; $user["role"] = "admin"; -if (!$user) { +if (!$admin) { session_destroy(); - header('Location: index.php?error=user_not_found'); + header('Location: /admin_login.php?error=user_not_found'); exit; } @@ -136,7 +137,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $id = $_POST['id']; if ($id != $_SESSION['user_id']) { // Foreign keys are ON DELETE CASCADE, so this is safe - $stmt = $pdo->prepare("DELETE FROM users WHERE id = ?"); + $stmt = $pdo->prepare("DELETE FROM admin_users WHERE id = ?"); $stmt->execute([$id]); } header('Location: admin.php?action=users'); diff --git a/assets/pasted-20260322-121049-fde8d6eb.png b/assets/pasted-20260322-121049-fde8d6eb.png new file mode 100644 index 0000000..7374899 Binary files /dev/null and b/assets/pasted-20260322-121049-fde8d6eb.png differ