This commit is contained in:
Flatlogic Bot 2026-03-22 12:13:08 +00:00
parent a0df7edb65
commit eecf468a95
2 changed files with 7 additions and 6 deletions

View File

@ -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');

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB