From ff4e747196abf64b58fd6693f63a646f9bd8944b Mon Sep 17 00:00:00 2001 From: deepend-tildeclub <58404188+deepend-tildeclub@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:31:20 -0700 Subject: [PATCH] Create setup.php --- polls/setup.php | 166 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 polls/setup.php diff --git a/polls/setup.php b/polls/setup.php new file mode 100644 index 0000000..c02894e --- /dev/null +++ b/polls/setup.php @@ -0,0 +1,166 @@ +query("SELECT COUNT(*) FROM users")->fetchColumn(); + +// If at least one user exists, show a message and no form +if ($checkTotal > 0) { + ?> + + + + + Setup Admin User + + + +
+

Admin User Already Exists

+

+ An admin user has already been created. No additional admins can be set up here. +

+

+ Go back to the Polls site. +

+
+ + + prepare(" + INSERT INTO users (username, password) + VALUES (:username, :password) + "); + $insertStmt->bindValue(':username', $username, PDO::PARAM_STR); + $insertStmt->bindValue(':password', $hashedPassword, PDO::PARAM_STR); + $insertStmt->execute(); + + $success = "Admin user '$username' created successfully."; + } +} +?> + + + + + Setup Admin User + + + +
+

Setup Admin User

+ + +
+ + +
+

You can now go to the Admin page to log in.

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ +
+ +