Website Summary Files Commits Branches @commit @diff @stats
path: root / controllers / user.php
diff options
context:
space:
mode:
Commit254e643a4f74a8b499093b303b831d80de5464ea (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-02 12:29:29 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-02 12:29:29 +0200
Files32e1bb071fcf47824334711904c6660ec069251a /controllers/user.php
nowayforward_human-254e643a4f74a8b499093b303b831d80de5464ea.tar
nowayforward_human-254e643a4f74a8b499093b303b831d80de5464ea.tar.gz
nowayforward_human-254e643a4f74a8b499093b303b831d80de5464ea.zip
Parent0d5738a2bc9dd4f5edf582f7cea3614bcbb44842 (diff)
feat(views): Move register to user/create
1 files changed, 23 insertions, 0 deletions
-rw-r--r--controllers/user.php23
diff --git a/controllers/user.php b/controllers/user.php
new file mode 100644
index 0000000..6c0c105
--- /dev/null
+++ b/controllers/user.php
@@ -0,0 +1,23 @@
+<?php
+namespace Controller;
+use Database;
+use Exception;
+
+function on_post() {
+ global $user_status;
+ $user_status = "";
+
+ try {
+ Database\User::fromDB($_POST["username"]);
+ $user_status = "User \"" . $_POST["username"] . "\" already exists!";
+ return;
+ }
+ catch(Exception $e) {}
+
+ try {
+ Database\User::create($_POST["username"], $_POST["password"], "User");
+ }
+ catch(Exception $e) {
+ $user_status = $e;
+ }
+}