Abgleich mit Live-Daten
This commit is contained in:
@@ -1,78 +1,78 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/functions.inc.php");
|
||||
//Überprüfe, dass der User eingeloggt ist
|
||||
//Der Aufruf von check_user() muss in alle internen Seiten eingebaut sein
|
||||
$user = check_user();
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<?php
|
||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$mitarbeiter = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$mitarbeiter) {
|
||||
die('Mitarbeiter nicht gefunden!');
|
||||
}
|
||||
} else {
|
||||
die('Ungültige Anfrage!');
|
||||
}
|
||||
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if(isset($_GET['send'])) {
|
||||
$passwort = $_POST['passwort'];
|
||||
$passwort2 = $_POST['passwort2'];
|
||||
|
||||
if($passwort != $passwort2) {
|
||||
$msg = "Bitte identische Passwörter eingeben";
|
||||
} else { //Speichere neues Passwort und lösche den Code
|
||||
$passworthash = password_hash($passwort, PASSWORD_DEFAULT);
|
||||
$statement = $pdo->prepare("UPDATE users SET passwort = :passworthash, passwortcode = NULL, passwortcode_time = NULL WHERE id = :userid");
|
||||
$result = $statement->execute(array('passworthash' => $passworthash, 'userid'=> $id ));
|
||||
|
||||
if($result) {
|
||||
echo "<br><div class='alert alert-success' role='alert'>Das Passwort des Mitarbeiters wurde erfolgreich aktualisiert.</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Umleitung
|
||||
// header('Location: index.php');
|
||||
}else{
|
||||
?>
|
||||
|
||||
<div class="container small-container-500">
|
||||
|
||||
<h1>Neues Passwort vergeben</h1>
|
||||
|
||||
<?php echo "<h3>Passwort von Mitarbeiter: " . htmlspecialchars($mitarbeiter['vorname']) . " " . htmlspecialchars($mitarbeiter['nachname']) . " ändern.</h3>" ?>
|
||||
|
||||
<form action="?send=1&id=<?php echo htmlentities($_GET['id']); ?>" method="post">
|
||||
<label for="passwort">Bitte gib ein neues Passwort ein:</label><br>
|
||||
<input type="password" id="passwort" name="passwort" class="form-control" required><br>
|
||||
|
||||
<label for="passwort2">Passwort erneut eingeben:</label><br>
|
||||
<input type="password" id="passwort2" name="passwort2" class="form-control" required><br>
|
||||
|
||||
<input type="submit" value="Passwort speichern" class="btn btn-lg btn-primary btn-block">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back();">Zurück</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/functions.inc.php");
|
||||
//Überprüfe, dass der User eingeloggt ist
|
||||
//Der Aufruf von check_user() muss in alle internen Seiten eingebaut sein
|
||||
$user = check_user();
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<?php
|
||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$mitarbeiter = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$mitarbeiter) {
|
||||
die('Mitarbeiter nicht gefunden!');
|
||||
}
|
||||
} else {
|
||||
die('Ungültige Anfrage!');
|
||||
}
|
||||
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if(isset($_GET['send'])) {
|
||||
$passwort = $_POST['passwort'];
|
||||
$passwort2 = $_POST['passwort2'];
|
||||
|
||||
if($passwort != $passwort2) {
|
||||
$msg = "Bitte identische Passwörter eingeben";
|
||||
} else { //Speichere neues Passwort und lösche den Code
|
||||
$passworthash = password_hash($passwort, PASSWORD_DEFAULT);
|
||||
$statement = $pdo->prepare("UPDATE users SET passwort = :passworthash, passwortcode = NULL, passwortcode_time = NULL WHERE id = :userid");
|
||||
$result = $statement->execute(array('passworthash' => $passworthash, 'userid'=> $id ));
|
||||
|
||||
if($result) {
|
||||
echo "<br><div class='alert alert-success' role='alert'>Das Passwort des Mitarbeiters wurde erfolgreich aktualisiert.</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Umleitung
|
||||
// header('Location: index.php');
|
||||
}else{
|
||||
?>
|
||||
|
||||
<div class="container small-container-500">
|
||||
|
||||
<h1>Neues Passwort vergeben</h1>
|
||||
|
||||
<?php echo "<h3>Passwort von Mitarbeiter: " . htmlspecialchars($mitarbeiter['vorname']) . " " . htmlspecialchars($mitarbeiter['nachname']) . " ändern.</h3>" ?>
|
||||
|
||||
<form action="?send=1&id=<?php echo htmlentities($_GET['id']); ?>" method="post">
|
||||
<label for="passwort">Bitte gib ein neues Passwort ein:</label><br>
|
||||
<input type="password" id="passwort" name="passwort" class="form-control" required><br>
|
||||
|
||||
<label for="passwort2">Passwort erneut eingeben:</label><br>
|
||||
<input type="password" id="passwort2" name="passwort2" class="form-control" required><br>
|
||||
|
||||
<input type="submit" value="Passwort speichern" class="btn btn-lg btn-primary btn-block">
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back();">Zurück</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
Reference in New Issue
Block a user