From 8758254a0f0997f8a3810f8588b5a194f91996f5 Mon Sep 17 00:00:00 2001 From: Tim Krehan Date: Sat, 10 Nov 2018 16:52:47 +0100 Subject: [PATCH] adduser call via ajax --- bin/adduser.js | 25 +++++++++++++++++++++++++ cont/.htaccess | 4 ++-- cont/adduser.php | 13 ++++++------- install/adduser.php | 12 ++++++++---- php/adduser_action.php | 15 --------------- style/adduser.css | 5 +++++ 6 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 bin/adduser.js delete mode 100644 php/adduser_action.php diff --git a/bin/adduser.js b/bin/adduser.js new file mode 100644 index 0000000..d074218 --- /dev/null +++ b/bin/adduser.js @@ -0,0 +1,25 @@ +$(document).ready(function(){ + $("#button_newuser").click(function(){ + $.post("/php/edit-user.php", + { + function: "new-user", + username: $("#text_user").val(), + passwd: $("#text_passwd").val() + }, + function(data){ + if(data==0){ + infoPopUp("Benutzer erfolgreich erstellt!"); + $("#text_user").val(""); + $("#text_passwd").val(""); + $("#adduser-button-done").removeClass("button-disabled"); + } + else { + infoPopUp("Fehler bei der Benutzeranlage!"); + } + } + ); + }); + $("#adduser-button-done").click(function(){ + window.location.href = "/"; + }); +}); diff --git a/cont/.htaccess b/cont/.htaccess index 6f56351..98e9e6d 100644 --- a/cont/.htaccess +++ b/cont/.htaccess @@ -1,4 +1,4 @@ # prevent access to these files while not logged in - -Require all denied + + Require all denied diff --git a/cont/adduser.php b/cont/adduser.php index 1934912..8516eba 100644 --- a/cont/adduser.php +++ b/cont/adduser.php @@ -1,14 +1,13 @@ - - + + +

Benutzer hinzufügen

-
+
- - - - +
+ diff --git a/install/adduser.php b/install/adduser.php index 1934912..06fa697 100644 --- a/install/adduser.php +++ b/install/adduser.php @@ -2,13 +2,17 @@ + + +

Benutzer hinzufügen

-
+
- - +
+ - + +
diff --git a/php/adduser_action.php b/php/adduser_action.php deleted file mode 100644 index 3bd10d6..0000000 --- a/php/adduser_action.php +++ /dev/null @@ -1,15 +0,0 @@ -query("INSERT INTO `users` (`username`, `password`, `salt`, `last_login`) VALUES ('".$_POST["username"]."', '".$password."', '".$salt."', CURRENT_TIMESTAMP);"); -$mysqli->close(); - -unset($salt); -unset($password); -header("Location: /"); -?> diff --git a/style/adduser.css b/style/adduser.css index 8ba74e0..31df069 100644 --- a/style/adduser.css +++ b/style/adduser.css @@ -13,3 +13,8 @@ label { flex-direction: column; width: 50%; } +#adduser-button-done { + position: absolute; + bottom: 2em; + right: 2em; +}