From 87ffa36c1bfa49259e48d94f09e64f83632f0071 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 13 Apr 2023 15:47:15 +0200 Subject: v1.0.0 --- users.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 users.php (limited to 'users.php') diff --git a/users.php b/users.php new file mode 100644 index 0000000..e1b1e18 --- /dev/null +++ b/users.php @@ -0,0 +1,99 @@ +setAttribute(PDO::ATTR_EMULATE_PREPARES, false); +$stmt = $pdo->prepare("SELECT * FROM `cms_user`"); +$stmt->execute(); +$users = $stmt->fetchAll(PDO::FETCH_ASSOC); + +function strStartsWith(string $needle, string $haystack) +{ + return substr($haystack, 0, strlen($needle)) === $needle; +} +if (isset($_GET["userEditType"])) { + $type = explode('!', $_GET["userEditType"]); + $_SESSION["u_Type"] = $type[0]; + if (strStartsWith("Edit", $_GET["userEditType"]) === true || strStartsWith("Remove", $_GET["userEditType"]) === true) { + $stmt = $pdo->prepare("SELECT * FROM `cms_user` WHERE `id`=:id"); + $stmt->execute(["id" => $type[1]]); + $user = $stmt->fetchAll(PDO::FETCH_ASSOC)[0]; + $_SESSION["u_Id"] = $user["id"]; + $_SESSION["u_Firstname"] = $user["firstname"]; + $_SESSION["u_Lastname"] = $user["lastname"]; + $_SESSION["u_Login"] = $user["login"]; + $_SESSION["u_Password"] = $user["password"]; + $_SESSION["u_Email"] = $user["email"]; + $_SESSION["u_user_type"] = $user["user_type"]; + } elseif (strStartsWith("Add", $_GET["userEditType"]) === true) { + $_SESSION["u_Id"] = ""; + $_SESSION["u_Firstname"] = ""; + $_SESSION["u_Lastname"] = ""; + $_SESSION["u_Login"] = ""; + $_SESSION["u_Password"] = ""; + $_SESSION["u_Email"] = ""; + $_SESSION["u_user_type"] = ""; + } elseif (strStartsWith("Remove", $_GET["userEditType"]) === true) { + $_SESSION["u_Id"] = $type[1]; + } + header("Location: userEdit.php"); + exit(); +} +?> + + + + + + + + + + + + + sCMS - Users + + + +
+ + + + + + + + + + + + + + + + + + "; + } + ?> + +
IdNameLoginAccount typeEdit
{$user["id"]}{$user["firstname"]} {$user["lastname"]}{$user["login"]}{$UserType[$user["user_type"]]} + Edit    + Remove +
+ Go to main + Add +
+ + + + \ No newline at end of file -- cgit v1.3.1