mirror of
https://github.com/tim-krehan/shopping-list.git
synced 2024-11-27 15:40:00 +01:00
installation add user via class
This commit is contained in:
parent
5af2219bac
commit
2f3c8f7390
4 changed files with 39 additions and 9 deletions
|
@ -1,12 +1,14 @@
|
||||||
<?php ?>
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="/style/master.css">
|
<link rel="stylesheet" href="/style/master.css">
|
||||||
<link rel="stylesheet" href="/style/adduser.css">
|
<link rel="stylesheet" href="/style/adduser.css">
|
||||||
</head>
|
</head>
|
||||||
<h1>Benutzer hinzufügen</h1>
|
<h1>Benutzer hinzufügen</h1>
|
||||||
<form class="adduser" action="/php/adduser_action.php" method="post">
|
<form class="adduser" action="/php/edit-user.php" method="post">
|
||||||
<label for="text_user">Benutzername</label><input id="text_user" type="text" name="username" value="" placeholder="user1" required>
|
<label for="text_user">Benutzername</label><input id="text_user" type="text" name="username" placeholder="user" required>
|
||||||
<label for="text_passwd">Passwort</label><input id="text_passwd" type="Password" name="passwd" value="" placeholder="********" required>
|
<label for="text_passwd">Passwort</label><input id="text_passwd" type="password" name="passwd" placeholder="********" required>
|
||||||
|
<input type="text" name="function" value="new-user" hidden>
|
||||||
<input id="button_newuser" class="button" type="submit" name="" value="Neuer Benutzer">
|
<input id="button_newuser" class="button" type="submit" name="" value="Neuer Benutzer">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- TODO: ADD JQUERY CALL TO EDIT-USER.PHP WITH FEEDBACK VIA JS FUNCTION INFOPOPUP() -->
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<?php ?>
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="/style/master.css">
|
<link rel="stylesheet" href="/style/master.css">
|
||||||
<link rel="stylesheet" href="/style/adduser.css">
|
<link rel="stylesheet" href="/style/adduser.css">
|
||||||
</head>
|
</head>
|
||||||
<h1>Benutzer hinzufügen</h1>
|
<h1>Benutzer hinzufügen</h1>
|
||||||
<form class="adduser" action="/php/adduser_action.php" method="post">
|
<form class="adduser" action="/php/edit-user.php" method="post">
|
||||||
<label for="text_user">Benutzername</label><input id="text_user" type="text" name="username" value="" placeholder="user1" required>
|
<label for="text_user">Benutzername</label><input id="text_user" type="text" name="username" placeholder="user" required>
|
||||||
<label for="text_passwd">Passwort</label><input id="text_passwd" type="Password" name="passwd" value="" placeholder="********" required>
|
<label for="text_passwd">Passwort</label><input id="text_passwd" type="password" name="passwd" placeholder="********" required>
|
||||||
|
<input type="text" name="function" value="new-user" hidden>
|
||||||
<input id="button_newuser" class="button" type="submit" name="" value="Neuer Benutzer">
|
<input id="button_newuser" class="button" type="submit" name="" value="Neuer Benutzer">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- TODO: ADD JQUERY CALL TO EDIT-USER.PHP WITH FEEDBACK VIA JS FUNCTION INFOPOPUP() -->
|
||||||
|
|
|
@ -32,5 +32,25 @@
|
||||||
print_r("1");
|
print_r("1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function new($uname, $password){
|
||||||
|
session_start();
|
||||||
|
include $_SESSION["docroot"].'/php/connect.php';
|
||||||
|
include $_SESSION["docroot"].'/php/hash.php';
|
||||||
|
|
||||||
|
$query = "SELECT `uid` FROM `users` WHERE `username` = '$uname'";
|
||||||
|
$result = $mysqli->query($query);
|
||||||
|
if($result->num_rows==0){
|
||||||
|
$salt = create_salt();
|
||||||
|
$passhash = hash_password($password, $salt);
|
||||||
|
$query = "INSERT INTO `users` (`username`, `password`, `salt`, `last_login`) VALUES ('$uname', '$passhash', '$salt', CURRENT_TIMESTAMP);";
|
||||||
|
$result = $mysqli->query($query);
|
||||||
|
unset($salt);
|
||||||
|
unset($password);
|
||||||
|
print_r(0);
|
||||||
|
}
|
||||||
|
else{print_r(1);}
|
||||||
|
$mysqli->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -2,13 +2,19 @@
|
||||||
session_start();
|
session_start();
|
||||||
include $_SESSION["docroot"].'/php/classes.user.php';
|
include $_SESSION["docroot"].'/php/classes.user.php';
|
||||||
$user = new user;
|
$user = new user;
|
||||||
|
if($_POST["function"]!="new-user"){
|
||||||
$user->get_info($_COOKIE["token"]);
|
$user->get_info($_COOKIE["token"]);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($_POST["function"]) {
|
switch ($_POST["function"]) {
|
||||||
case 'change-pw':
|
case 'change-pw':
|
||||||
$user->change_password($_POST["current"], $_POST["new"]);
|
$user->change_password($_POST["current"], $_POST["new"]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'new-user':
|
||||||
|
$user->new($_POST["username"], $_POST["passwd"]);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// code...
|
// code...
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue