From 2a3f639a66973614186d0839cc1d3a85e36008f2 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 21 May 2024 17:49:42 +0200 Subject: [PATCH] created php api for user removing --- res/forum/api/remove_user.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 res/forum/api/remove_user.php diff --git a/res/forum/api/remove_user.php b/res/forum/api/remove_user.php new file mode 100644 index 0000000..bcbcef9 --- /dev/null +++ b/res/forum/api/remove_user.php @@ -0,0 +1,23 @@ + query("SELECT username, admin FROM user WHERE username=\"" . $_SESSION["username"] . "\" AND admin=\"1\""); + +if ($out -> num_rows != 1) +{ + fail: + echo "nope"; + header("Location: ../../../index.php"); + return; +} + +if (!isset($_GET["username"])) return; + +$user_info_id = (($database -> query("SELECT user_info FROM user WHERE username=\"" . $_GET["username"] . "\"")) -> fetch_assoc())["user_info"]; + +$database -> query("DELETE FROM user WHERE user_info=" . $user_info_id); +$database -> query("DELETE FROM user_info WHERE id=" . $user_info_id); \ No newline at end of file