1
0
mirror of synced 2025-12-28 00:23:25 +00:00

feat(stops) caching stops

This commit is contained in:
Valentin
2024-06-14 16:59:36 +02:00
parent 1d20fd7815
commit cf5f96f47b
7 changed files with 79 additions and 57 deletions

View File

@@ -16,8 +16,6 @@ function getUsers() {
}
}
$users = getUsers();
function updateUserDetails($userId, $email, $firstName, $lastName, $is_admin, $password = null) {
global $conn;
try {
@@ -46,39 +44,9 @@ function deleteUser($userId) {
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['userId'])) {
if (isset($_POST['delete'])) {
if ($_POST['userId'] == $_SESSION['user_id']) {
echo 222;
$_SESSION['message'] = '<div class="alert alert-danger text-center" role="alert">You cannot delete yourself.</div>';
header("Location: " . $_SERVER['REQUEST_URI']);
exit();
}
$success = deleteUser($_POST['userId']);
if ($success) {
$_SESSION['message'] = '<div class="alert alert-success text-center" role="alert">User deleted successfully.</div>';
} else {
$_SESSION['message'] = '<div class="alert alert-danger text-center" role="alert">Failed to delete user.</div>';
}
header("Location: " . $_SERVER['REQUEST_URI']);
exit();
}
$password = !empty($_POST['password']) ? $_POST['password'] : null;
$_POST['is_admin'] = isset($_POST['is_admin']) ? 1 : 0;
$users = getUsers();
$success = updateUserDetails($_POST['userId'], $_POST['email'], $_POST['firstName'], $_POST['lastName'], $_POST['is_admin'], $password);
if ($success) {
$_SESSION['message'] = '<div class="alert alert-success text-center" role="alert">User updated successfully.</div>';
} else {
$_SESSION['message'] = '<div class="alert alert-danger text-center" role="alert">Failed to update user.</div>';
}
header("Location: " . $_SERVER['REQUEST_URI']);
exit();
}
include 'post.php';
?>