added user managment
This commit is contained in:
60
app/public/add_user.php
Normal file
60
app/public/add_user.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
session_start();
|
||||
include("../scripts/connection.php");
|
||||
include("../scripts/functions.php");
|
||||
$user_data = check_admin($con);
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$user_name = $_POST['user_name'];
|
||||
$password = $_POST['password'];
|
||||
$user_group = $_POST['user_group'];
|
||||
$bind_station = $_POST['bind_station'];
|
||||
if(!empty($user_name) && !empty($password)) {
|
||||
$salt = generate_salt();
|
||||
$user_id = generate_user_id($_POST['user_name'], $salt);
|
||||
$phash = generate_password_hash($_POST['password'], $salt);
|
||||
if($user_group == "station") {
|
||||
write_user($con, $user_name, $user_id, $phash, $salt, $user_group, $bind_station);
|
||||
} else {
|
||||
write_user($con, $user_name, $user_id, $phash, $salt, $user_group, NULL);
|
||||
}
|
||||
} else {
|
||||
echo "Bitte Benutzername und Passwort eintragen!";
|
||||
}
|
||||
}
|
||||
|
||||
include("header_footer/header.php");
|
||||
?>
|
||||
|
||||
<body>
|
||||
<div class="headline">
|
||||
<h2>Benutzer hinzufügen</h2>
|
||||
</div>
|
||||
<div>
|
||||
<form method="post">
|
||||
<label for="user_name">Benutzername</label>
|
||||
<input type="text" name="user_name"/><br>
|
||||
<label for="password">Passwort</label>
|
||||
<input type="password" name="password"/><br>
|
||||
<label for="user_group">Benutzergruppe</label>
|
||||
<select name="user_group" id="user_group">
|
||||
<option value="station">Station</option>
|
||||
<option value="statistics">Statistik</option>
|
||||
<option value="admin">Administrator</option>
|
||||
</select><br>
|
||||
<label for="bind_station">Gebunden an Station:</label>
|
||||
<select name="bind_station" id="bind_station">
|
||||
<?php
|
||||
load_options_stations($con, "", false);
|
||||
?>
|
||||
</select>
|
||||
<label for="bind_station">(Nur für Benutzergruppe Station)</label><br>
|
||||
<input type="submit" value="Hinzufügen"/>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<?php
|
||||
$con = null;
|
||||
echo file_get_contents("header_footer/footer.html");
|
||||
?>
|
||||
Reference in New Issue
Block a user