select table rows and edit user

This commit is contained in:
2022-06-10 14:10:34 +02:00
parent 3c613cca33
commit 43c33b55d6
11 changed files with 200 additions and 6 deletions

72
app/public/edit_user.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
session_start();
include("../scripts/connection.php");
include("../scripts/functions.php");
$user_data = check_admin($con);
if($_SERVER['REQUEST_METHOD'] == "GET") {
$row = get_user($con, $_GET['id'])->fetch();
include("header_footer/header.php");
}
if($_SERVER['REQUEST_METHOD'] == "POST") {
$user = get_user($con, $_POST['id'])->fetch();
if($user['user_name'] != $_POST['user_name']) {
change_user_name($con, $_POST['id'], $_POST['user_name']);
}
if($user['user_group'] != $_POST['user_group']) {
if($_POST['user_group'] == "station") {
change_user_group($con, $_POST['id'], $_POST['user_group'], $_POST['bind_station']);
} else {
change_user_group($con, $_POST['id'], $_POST['user_group'], NULL);
}
}
if(!empty($_POST['password'])) {
$phash = generate_password_hash($_POST['password'], $user['salt']);
change_password($con, $_POST['id'], $phash);
}
header("Location: manage_user.php");
die;
}
?>
<body>
<div class="headline">
<h2>Benutzer bearbeiten</h2>
</div>
<div>
<form method="post">
<label for="user_name">Benutzername:</label>
<input name="user_name" type="text" value=<?php echo "\"" . $row['user_name'] . "\"";?>/><br>
<label for="password">Neues Passwort:</label>
<input type="password" name="password"/><br>
<label for="user_group">Benutzergruppe:</label>
<select name="user_group" id="user_group">
<option value="station" <?php if($row['user_group'] == "station"){echo " selected";}?>>Station</option>
<option value="statistics" <?php if($row['user_group'] == "statistics") {echo " selected";}?>>Statistik</option>
<option value="admin" <?php if($row['user_group'] == "admin") {echo " selected";}?>>Admin</option>
</select><br>
<label for="bind_station">Gebunden an Station:</label>
<select name="bind_station" id="bind_station">
<?php
if($row['s_id'] == null) {
load_options_stations($con, "", false);
} else {
load_options_stations($con, $row['s_id'], false);
}
?>
</select>
<label for="bind_station">(Nur für Benutzergruppe Station)</label><br>
<input type="hidden" value=<?php echo "\"" . $row['id'] . "\""?> name="id"/>
<input type="submit" value="ändern">
</form>
</div>
</body>
<?php
$con = null;
echo file_get_contents("header_footer/footer.html");
?>