diff --git a/components/admin/main.php b/components/admin/main.php index d0c2cb0..a7e52b2 100644 --- a/components/admin/main.php +++ b/components/admin/main.php @@ -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'] = ''; - header("Location: " . $_SERVER['REQUEST_URI']); - exit(); - } - $success = deleteUser($_POST['userId']); - if ($success) { - $_SESSION['message'] = ''; - } else { - $_SESSION['message'] = ''; - } - 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'] = ''; - } else { - $_SESSION['message'] = ''; - } - - header("Location: " . $_SERVER['REQUEST_URI']); - exit(); -} +include 'post.php'; ?> diff --git a/components/admin/post.php b/components/admin/post.php new file mode 100644 index 0000000..dd3eb3a --- /dev/null +++ b/components/admin/post.php @@ -0,0 +1,37 @@ +You cannot delete yourself.'; + header("Location: " . $_SERVER['REQUEST_URI']); + exit(); + } + $success = deleteUser($_POST['userId']); + if ($success) { + $_SESSION['message'] = ''; + } else { + $_SESSION['message'] = ''; + } + header("Location: " . $_SERVER['REQUEST_URI']); + exit(); + } + + $password = !empty($_POST['password']) ? $_POST['password'] : null; + $_POST['is_admin'] = isset($_POST['is_admin']) ? 1 : 0; + + + $success = updateUserDetails($_POST['userId'], $_POST['email'], $_POST['firstName'], $_POST['lastName'], $_POST['is_admin'], $password); + + if ($success) { + $_SESSION['message'] = ''; + } else { + $_SESSION['message'] = ''; + } + + header("Location: " . $_SERVER['REQUEST_URI']); + exit(); +} + +?> \ No newline at end of file diff --git a/components/homepage/main.php b/components/homepage/main.php index 414aa66..e0d0355 100644 --- a/components/homepage/main.php +++ b/components/homepage/main.php @@ -29,7 +29,7 @@ $lineIds = $query->fetchAll(PDO::FETCH_COLUMN); ?>
-

Subway Schedule

+

Subways

Displaying your favorite stations and lines below

@@ -46,7 +46,6 @@ if (empty($lineIds)) { } ?> -