76 lines
2.8 KiB
PHP
76 lines
2.8 KiB
PHP
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Scolify - Schule Lachenzelg</title>
|
|
<link rel="shortcut icon" type="image/png" href="assets/images/logos/favicon.png" />
|
|
<link rel="stylesheet" href="assets/css/styles.min.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<!-- Body Wrapper -->
|
|
<div class="page-wrapper" id="main-wrapper" data-layout="vertical" data-navbarbg="skin6" data-sidebartype="full"
|
|
data-sidebar-position="fixed" data-header-position="fixed">
|
|
<div
|
|
class="position-relative overflow-hidden radial-gradient min-vh-100 d-flex align-items-center justify-content-center">
|
|
<div class="d-flex align-items-center justify-content-center w-100">
|
|
<div class="row justify-content-center w-100">
|
|
<div class="col-md-8 col-lg-6 col-xxl-3">
|
|
<div class="card mb-0">
|
|
<div class="card-body">
|
|
<a href="./index.php" class="text-nowrap logo-img text-center d-block py-3 w-100">
|
|
<img src="assets/images/logos/login.png" width="180" alt="">
|
|
</a>
|
|
|
|
<form action="forgot_password.php" method="POST">
|
|
<label for="user_id">Benutzer-ID:</label>
|
|
<input type="text" name="user_id" required>
|
|
<button class="btn btn-primary py-8 fs-4 w-100 mb-2 mt-3 rounded-2" type="btn submit">Passwort zurücksetzen</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="assets/libs/jquery/dist/jquery.min.js"></script>
|
|
<script src="assets/libs/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
|
|
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$userId = $_POST['user_id'];
|
|
|
|
// Hole den Benutzer anhand der User-ID
|
|
$userResponse = getById('tbl_students', $userId);
|
|
|
|
if ($userResponse['status'] == 200) {
|
|
$user = $userResponse['data'];
|
|
|
|
// Überprüfe, ob eine E-Mail-Adresse für den Benutzer vorhanden ist
|
|
if (!empty($user['emailstudent'])) {
|
|
// Generiere ein Token für das Zurücksetzen des Passworts
|
|
$token = bin2hex(random_bytes(50));
|
|
$expiry = date('Y-m-d H:i:s', strtotime('+1 hour'));
|
|
|
|
// Speichere das Token und das Ablaufdatum in der Datenbank
|
|
saveResetToken($user['id'], $token, $expiry);
|
|
|
|
// Sende die E-Mail mit dem Token-Link
|
|
$resetLink = "http://localhost/reset_password.php?token=$token";
|
|
mail($user['emailstudent'], "Passwort zurücksetzen", "Klicke auf diesen Link, um dein Passwort zurückzusetzen: $resetLink");
|
|
|
|
echo "Überprüfe deine E-Mails, um dein Passwort zurückzusetzen.";
|
|
}
|
|
}
|
|
}
|
|
?>
|