From 3afced16db44c50e4d23254a201116ac9c28430e Mon Sep 17 00:00:00 2001 From: "hamza.sarwar" Date: Tue, 14 Jan 2025 07:44:19 +0100 Subject: [PATCH] =?UTF-8?q?Forgot-Password=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/function.php | 33 ++++++++++++++++++++ forgot-password.php | 0 forgot_password.php | 75 +++++++++++++++++++++++++++++++++++++++++++++ index.php | 2 +- reset_password.php | 30 ++++++++++++++++++ 5 files changed, 139 insertions(+), 1 deletion(-) delete mode 100644 forgot-password.php create mode 100644 forgot_password.php create mode 100644 reset_password.php diff --git a/config/function.php b/config/function.php index 8ee1f8b..e58cd68 100644 --- a/config/function.php +++ b/config/function.php @@ -64,6 +64,18 @@ function getAll($columnname,$tablename,$conditionvalue = "") return $result; } +function saveResetToken($userId, $token, $expiry) { + global $conn; + $userId = validate($userId); + $token = validate($token); + $expiry = validate($expiry); + + $query = "UPDATE users SET reset_token='$token', reset_token_expiry='$expiry' WHERE userid='$userId'"; + $result = mysqli_query($conn, $query); + + return $result; +} + function getById($tableName, $id) { global $conn; @@ -918,6 +930,27 @@ function getStudentAssignments($studentID) } } +function updatePassword($userId, $newPassword) { + global $conn; + $userId = validate($userId); + $newPassword = validate($newPassword); + + $query = "UPDATE users SET password='$newPassword' WHERE id='$userId'"; + $result = mysqli_query($conn, $query); + + return $result; +} + +function deleteResetToken($userId) { + global $conn; + $userId = validate($userId); + + $query = "UPDATE users SET reset_token=NULL, reset_token_expiry=NULL WHERE id='$userId'"; + $result = mysqli_query($conn, $query); + + return $result; +} + function isStudentRegisteredForCourse($studentId, $courseId) { // Hier eine Abfrage zur Datenbank machen, um zu prüfen, ob ein Eintrag in tbl_assign_students_courses existiert global $conn; // Annahme, dass $conn die Datenbankverbindung ist diff --git a/forgot-password.php b/forgot-password.php deleted file mode 100644 index e69de29..0000000 diff --git a/forgot_password.php b/forgot_password.php new file mode 100644 index 0000000..9ae44f5 --- /dev/null +++ b/forgot_password.php @@ -0,0 +1,75 @@ + + + + + + + Scolify - Schule Lachenzelg + + + + + + +
+
+
+
+
+
+
+ + + + +
+ + + +
+
+
+
+
+
+
+
+ + + + + + + + + + diff --git a/index.php b/index.php index 3ae1b49..66a4dc5 100644 --- a/index.php +++ b/index.php @@ -49,7 +49,7 @@ Beispiel: 06.04.2002
- Kennwort vergessen? + Kennwort vergessen?
diff --git a/reset_password.php b/reset_password.php new file mode 100644 index 0000000..69e48e9 --- /dev/null +++ b/reset_password.php @@ -0,0 +1,30 @@ + + +
+ + + +