From 39c8234b6d2923c861c96e39b9519f15ccfa6728 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 27 Mar 2026 08:14:22 +0100 Subject: [PATCH] Files from 27-03-26: Password Hashing and checks for password stregnth --- Zweites Jahr/README.md | 4 ++ .../unterrichts_projekt/portal/functions.php | 47 +++++++++++++++++++ .../unterrichts_projekt/portal/register.php | 15 +++++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Zweites Jahr/unterrichts_projekt/portal/functions.php diff --git a/Zweites Jahr/README.md b/Zweites Jahr/README.md index 0f4b813..995b9e3 100644 --- a/Zweites Jahr/README.md +++ b/Zweites Jahr/README.md @@ -7,6 +7,10 @@ Wichtige Informationen - Wird eventuell nie aktuell sein. - Stundenplan - [Link](https://wvss-mannheim.webuntis.com/WebUntis/?school=wvss-mannheim#/basic/timetablePublic/class?entityId=2583) +## 27-03-26 - PHP (Unterrichts Projekt) +- Registrierung weiter gemacht + - Passwort checks + - Passwort hashing ## 25-03-26 - PHP (Unterrichts Projekt) - Registrierung gemacht diff --git a/Zweites Jahr/unterrichts_projekt/portal/functions.php b/Zweites Jahr/unterrichts_projekt/portal/functions.php new file mode 100644 index 0000000..7191ae1 --- /dev/null +++ b/Zweites Jahr/unterrichts_projekt/portal/functions.php @@ -0,0 +1,47 @@ + + + += 8) $strength++; + + //check if caps + if(preg_match('/[A-Z]/', $password)) $strength++; + + //check if lower cases + if(preg_match('/[a-z]/', $password)) $strength++; + + //check if numbers + if(preg_match('/[0-9]/', $password)) $strength++; + + //check if spec. chars + if(preg_match('/[^a-zA-Z0-9]/', $password)) $strength++; + + return($strength >= 5); + + +} \ No newline at end of file diff --git a/Zweites Jahr/unterrichts_projekt/portal/register.php b/Zweites Jahr/unterrichts_projekt/portal/register.php index fdd9d01..1e55247 100644 --- a/Zweites Jahr/unterrichts_projekt/portal/register.php +++ b/Zweites Jahr/unterrichts_projekt/portal/register.php @@ -14,8 +14,11 @@ + + "; + } + $query = "INSERT INTO user VALUES (NULL, :email, :pw)"; $stmt = $dbh->prepare($query); @@ -36,13 +45,17 @@ if(!empty($_REQUEST)) { // Button wurde gedrückt? $errMsg = $e->getMessage(); $errCode = $e->getCode(); + echo $e; + switch($errCode) { case "23000": $custErrMsg = "

Email-Adress already exists!

"; break; default: $custErrMsg = "

Oooops, something went wrong!

"; } echo $custErrMsg; } - } + } else { + $errors .= "Beide Felder müssen ausgefüllt werden
"; + } // Ende Felder müssen ausgefüllt werden. }