diff --git a/CSS/Element/button.css b/CSS/Element/button.css index 8df442c..5b83ca3 100644 --- a/CSS/Element/button.css +++ b/CSS/Element/button.css @@ -1,3 +1,10 @@ +.buttons-container{ + display: flex; + justify-content: space-between; + align-items: center; + gap: 10px; +} + .btn{ background: var(--brand-primary); color: var(--brand-white); @@ -21,6 +28,10 @@ aspect-ratio: 1/1; } +.btn-login{ + background-color: transparent; +} + .btn-user > span { font-size: 28px; } \ No newline at end of file diff --git a/Controller/UserController.php b/Controller/UserController.php index a58a4fc..4205514 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -10,13 +10,32 @@ class UserController{ private $validData = array(); private $errors = array(); + private $labels = [ + "name" => "Vorname*", + "lastname" => "Nachname*", + "email" => "E-Mail*", + "password" => "Passwort*", + "role" => "Rolle*" + ]; + + private $validLoginData = array(); + private $loginErrors = array(); + private $loginLabels = [ + "email" => "E-Mail*", + "password" => "Passwort*", + ]; + public function __construct($view){ $this->db = new UserModel(); $this->view = $view; } public function showUserRegisterForm(){ - + $this->view->setVars([ + 'labels' => $this->labels, + 'errors' => $this->errors, + 'validData' => $this->validData + ]); } public function showUserRegisterConfirmation(){ @@ -24,7 +43,45 @@ class UserController{ } public function showUserLoginForm(){ + $this->view->setVars([ + 'labels' => $this->loginLabels, + 'errors' => $this->loginErrors, + 'validData' => $this->validLoginData + ]); + } + private function validateForm() { + foreach ($this->labels as $key => $label) { + if (!isset($_POST[$key]) || trim($_POST[$key]) === '') { + $this->errors[$key] = "Bitte $label angeben"; + } else { + $this->validData[$key] = trim($_POST[$key]); + } + } + + if (isset($this->validData['password'])) { + if (strlen($this->validData['password']) < 6) { + $this->errors['password'] = "Das Passwort muss mindestens 6 Zeichen lang sein."; + } + } + + if (isset($this->validData['email']) && !filter_var($this->validData['email'], FILTER_VALIDATE_EMAIL)) { + $this->errors['email'] = "Bitte eine gültige E-Mail-Adresse eingeben."; + } + } + + public function validateLoginForm(){ + foreach ($this->loginLabels as $key => $label) { + if (isset($this->validData['password'])) { + if (strlen($this->validData['password']) < 6) { + $this->errors['password'] = "Das Passwort muss mindestens 6 Zeichen lang sein."; + } + } + + if (isset($this->validData['email']) && !filter_var($this->validData['email'], FILTER_VALIDATE_EMAIL)) { + $this->errors['email'] = "Bitte eine gültige E-Mail-Adresse eingeben."; + } + } } public function showUserLoginConfirmation(){ diff --git a/Views/Admin/showForm.phtml b/Views/Admin/showForm.phtml index 2b7b1db..e66b63a 100644 --- a/Views/Admin/showForm.phtml +++ b/Views/Admin/showForm.phtml @@ -29,6 +29,7 @@ foreach ($labels as $key => $value) { - + + \ No newline at end of file diff --git a/Views/User/showUserLoginForm.phtml b/Views/User/showUserLoginForm.phtml index e541dbf..af1cff4 100644 --- a/Views/User/showUserLoginForm.phtml +++ b/Views/User/showUserLoginForm.phtml @@ -4,17 +4,32 @@