aboutsummaryrefslogtreecommitdiff
path: root/controllers/user.php
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/user.php')
-rw-r--r--controllers/user.php23
1 files changed, 23 insertions, 0 deletions
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;
+ }
+}