64 lines
2.3 KiB
PHP
64 lines
2.3 KiB
PHP
<?php
|
|
session_start();
|
|
include("../scripts/connection.php");
|
|
include("../scripts/functions.php");
|
|
$user_data = check_admin($con);
|
|
$error = null;
|
|
|
|
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);
|
|
}
|
|
header("Location: manage_user.php");
|
|
die;
|
|
} else {
|
|
$error = "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><?php echo $error ?></label><br>
|
|
<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");
|
|
?>
|