From 440e8f50feda7a3c1d78c16678624bfe8eaf4db1 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 19 Aug 2025 10:02:56 +0500 Subject: feat: edit account information + display it --- account/edit.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 24 +++++++++++++- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 account/edit.php diff --git a/account/edit.php b/account/edit.php new file mode 100644 index 0000000..9c46c02 --- /dev/null +++ b/account/edit.php @@ -0,0 +1,99 @@ + 20) { + exit(create_alert('/account/edit.php', 400, 'New username must be between 4 and 20 characters long', null)); + } + } + + $db = new PDO(DB_URL, DB_USER, DB_PASS); + + $db->prepare('UPDATE users SET username = ?, password = ? WHERE id = ?') + ->execute([$username, $password, $user['id']]); + + $user['username'] = $username; + $user['password'] = $password; + + $_SESSION['user'] = $user; + + exit(create_alert('/account/edit.php', 200, 'Success!', $user)); +} + +?> + + + + + id system + + + + +
+ + + +
+
+

Edit account information

+ + + + + + + + + + + + + + + + + +
Username
Password
+ +
+
+
+
+
+

Danger zone

+ +
+
+ + + \ No newline at end of file diff --git a/index.php b/index.php index 4256099..5a00c47 100644 --- a/index.php +++ b/index.php @@ -2,6 +2,7 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/partials.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/utils.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/config.php'; +include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/alert.php'; $user = $_SESSION['user'] ?: null; ?> @@ -16,9 +17,30 @@ $user = $_SESSION['user'] ?: null;
+ -

Hey,

+
+

Account information

+ + + + + + + + + + + + + + + + + +
Username
Password*****
Joined
+
-- cgit v1.2.3