diff --git a/Zweites Jahr/README.md b/Zweites Jahr/README.md
index 995b9e3..5b578e5 100644
--- a/Zweites Jahr/README.md
+++ b/Zweites Jahr/README.md
@@ -11,6 +11,7 @@ Wichtige Informationen
- Registrierung weiter gemacht
- Passwort checks
- Passwort hashing
+ - Email checking
## 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
index 7191ae1..a3d3b86 100644
--- a/Zweites Jahr/unterrichts_projekt/portal/functions.php
+++ b/Zweites Jahr/unterrichts_projekt/portal/functions.php
@@ -1,22 +1,5 @@
-
-
-
= 5);
-
+}
+function isValidEmail(string $email):bool {
+ return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}
\ 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 1e55247..7f2c25c 100644
--- a/Zweites Jahr/unterrichts_projekt/portal/register.php
+++ b/Zweites Jahr/unterrichts_projekt/portal/register.php
@@ -27,36 +27,36 @@ if(!empty($_REQUEST)) { // Button wurde gedrückt?
$email = $_REQUEST['email'];
$pw = $_REQUEST['pw'];
- if(isStrongPassword($pw)){ // hier kann man die gegeben Funktion nutzen oder "checkPAsswordStrength" (aus functions.php)
+ if(checkPasswordStrength($pw) AND isValidEmail($email)){
$pw = password_hash($pw, PASSWORD_DEFAULT);
- } else {
- $errors .= "Passwort zu schwach!
";
- }
- $query = "INSERT INTO user VALUES (NULL, :email, :pw)";
- $stmt = $dbh->prepare($query);
+ $query = "INSERT INTO user VALUES (NULL, :email, :pw)";
+ $stmt = $dbh->prepare($query);
- $stmt->bindParam(':email', $email);
- $stmt->bindParam(':pw', $pw);
+ $stmt->bindParam(':email', $email);
+ $stmt->bindParam(':pw', $pw);
- try {
- $stmt->execute();
- } catch(PDOException $e){
- $errMsg = $e->getMessage();
- $errCode = $e->getCode();
+ try {
+ $stmt->execute();
+ $errors = "Alles malocht! :)";
+ } catch(PDOException $e){
+ $errMsg = $e->getMessage();
+ $errCode = $e->getCode();
- echo $e;
+ echo $e;
- switch($errCode) {
- case "23000": $custErrMsg = "
Email-Adress already exists!
"; break; - default: $custErrMsg = "Oooops, something went wrong!
"; + switch($errCode) { + case "23000": $custErrMsg = "Email-Adress already exists!
"; break; + default: $custErrMsg = "Oooops, something went wrong!
"; + } + echo $custErrMsg; } - echo $custErrMsg; + } else { + $errors .= "Passwort zu schwach oder Email ist ungültig !