Registrierung und Login aufgeräumt: Felder und Fehler angepasst, Formulardaten bleiben bei Fehlern erhalten, Navigation zeigt jetzt nur noch passende Links je nach Login-Status, Passwort-Fehler verständlich auf Deutsch. Alles einheitlich und benutzerfreundlich gemacht!
This commit is contained in:
parent
404e846418
commit
a9997b3c63
@ -150,32 +150,63 @@ a {
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-container {
|
.form-container {
|
||||||
position: absolute;
|
|
||||||
top: 200px;
|
|
||||||
background-color: #BAC8D4;
|
background-color: #BAC8D4;
|
||||||
width: 900px;
|
width: 100%;
|
||||||
height: 450px;
|
max-width: 400px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
padding: 32px 24px 24px 24px;
|
||||||
|
margin: 32px auto;
|
||||||
}
|
}
|
||||||
|
.form-horizontal {
|
||||||
.event-container {
|
width: 100%;
|
||||||
position: absolute;
|
|
||||||
top: 200px;
|
|
||||||
background-color: #BAC8D4;
|
|
||||||
width: 900px;
|
|
||||||
height: 450px;
|
|
||||||
border-radius: 10px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
gap: 12px;
|
||||||
justify-content: center;
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.form-horizontal label {
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
.form-horizontal input[type="text"],
|
||||||
|
.form-horizontal input[type="email"],
|
||||||
|
.form-horizontal input[type="password"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border: 1px solid #BAC8D4;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 1rem;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.form-horizontal button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 0;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #4d4d4d;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1rem;
|
||||||
|
margin-top: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
.form-horizontal button:hover {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
.login-error, .form-error {
|
||||||
|
background: #ffe0e0;
|
||||||
|
color: #b30000;
|
||||||
|
border: 1px solid #ffb3b3;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 10px 16px;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
|
@ -63,14 +63,14 @@ class AuthController
|
|||||||
|
|
||||||
public function register() {
|
public function register() {
|
||||||
$data = [
|
$data = [
|
||||||
'first_name' => $_POST['vorname'] ?? '',
|
'first_name' => $_POST['first_name'] ?? '',
|
||||||
'last_name' => $_POST['nachname'] ?? '',
|
'last_name' => $_POST['last_name'] ?? '',
|
||||||
'street' => $_POST['strasse'] ?? '',
|
'street' => $_POST['street'] ?? '',
|
||||||
'house_number' => $_POST['hausnr'] ?? '',
|
'house_number' => $_POST['house_number'] ?? '',
|
||||||
'postal_code' => $_POST['plz'] ?? '',
|
'postal_code' => $_POST['postal_code'] ?? '',
|
||||||
'city' => $_POST['ort'] ?? '',
|
'city' => $_POST['city'] ?? '',
|
||||||
'country' => $_POST['land'] ?? '',
|
'country' => $_POST['country'] ?? '',
|
||||||
'phone' => $_POST['tel'] ?? '',
|
'phone' => $_POST['phone'] ?? '',
|
||||||
'email' => $_POST['email'] ?? '',
|
'email' => $_POST['email'] ?? '',
|
||||||
'password' => $_POST['password'] ?? '',
|
'password' => $_POST['password'] ?? '',
|
||||||
'password_repeat' => $_POST['password_repeat'] ?? '',
|
'password_repeat' => $_POST['password_repeat'] ?? '',
|
||||||
@ -80,13 +80,15 @@ class AuthController
|
|||||||
$result = $this->model->register($data);
|
$result = $this->model->register($data);
|
||||||
|
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$this->view->setVars(['success' => 'Registrierung erfolgreich!']);
|
$this->view->setDoMethodName('showRegistrationSuccess');
|
||||||
$this->view->render('Auth/showLoginForm');
|
|
||||||
exit;
|
|
||||||
} else {
|
} else {
|
||||||
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
|
if (is_array($result)) {
|
||||||
|
$errors['register'] = implode('<br>', $result);
|
||||||
|
} else {
|
||||||
|
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
|
||||||
|
}
|
||||||
$this->view->setVars(['errors' => $errors, 'validData' => $data]);
|
$this->view->setVars(['errors' => $errors, 'validData' => $data]);
|
||||||
$this->view->render('Auth/showRegistrationForm');
|
$this->view->setDoMethodName('showRegistrationForm');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Blog\Controller;
|
|
||||||
|
|
||||||
class RegisterController {
|
|
||||||
function showRegisterPage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Blog\Controller;
|
|
||||||
|
|
||||||
class WelcomeController
|
|
||||||
{
|
|
||||||
function showWelcome() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function showProjects() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function showTutorials() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -52,7 +52,7 @@ class AuthModel extends Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
$requiredFields = [
|
$requiredFields = [
|
||||||
'email', 'password', 'street', 'house_number', 'city', 'postal_code',
|
'email', 'password', 'password_repeat', 'street', 'house_number', 'city', 'postal_code',
|
||||||
'country', 'first_name', 'last_name', 'phone'
|
'country', 'first_name', 'last_name', 'phone'
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -71,8 +71,9 @@ class AuthModel extends Database
|
|||||||
return "Passwörter stimmen nicht überein.";
|
return "Passwörter stimmen nicht überein.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->pwRequirementCheck($data['password']) !== true) {
|
$pwCheck = $this->pwRequirementCheck($data['password']);
|
||||||
return "Passwort muss mindestens 8 Zeichen lang sein und mindestens ein Großbuchstabe, ein Kleinbuchstabe, eine Zahl und ein Sonderzeichen enthalten.";
|
if ($pwCheck !== true) {
|
||||||
|
return $pwCheck; // Array mit spezifischen Fehlern zurückgeben
|
||||||
}
|
}
|
||||||
|
|
||||||
$hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT);
|
$hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||||
@ -220,16 +221,16 @@ class AuthModel extends Database
|
|||||||
public function pwRequirementCheck($password){
|
public function pwRequirementCheck($password){
|
||||||
$error = [];
|
$error = [];
|
||||||
|
|
||||||
if(strlen($password) <= 8)
|
if(strlen($password) < 8)
|
||||||
$error[] = "min 8 Charackter";
|
$error[] = "Passwort: mindestens 8 Zeichen";
|
||||||
if(!preg_match("/[A-Z]/", $password))
|
if(!preg_match("/[A-Z]/", $password))
|
||||||
$error[] = "min one large Character";
|
$error[] = "Passwort: mindestens ein Großbuchstabe";
|
||||||
if(!preg_match("/[a-z]/", $password))
|
if(!preg_match("/[a-z]/", $password))
|
||||||
$error[] = "min one small charakter";
|
$error[] = "Passwort: mindestens ein Kleinbuchstabe";
|
||||||
if(!preg_match("/[0-9]/", $password))
|
if(!preg_match("/[0-9]/", $password))
|
||||||
$error[] = "min one number";
|
$error[] = "Passwort: mindestens eine Zahl";
|
||||||
if(!preg_match("[^a-zA-Z0-9\s]", $password));
|
if(!preg_match("/[^a-zA-Z0-9\s]/", $password))
|
||||||
$error[] = "min one special character";
|
$error[] = "Passwort: mindestens ein Sonderzeichen";
|
||||||
|
|
||||||
if(empty($error))
|
if(empty($error))
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<div class="inhalt">
|
<div class="inhalt">
|
||||||
<div class="login-container">
|
<div class="form-container">
|
||||||
<h1>Anmelden</h1>
|
<h1>Anmelden</h1>
|
||||||
<?php if (!empty($errors['login'])): ?>
|
<?php if (!empty($errors['login'])): ?>
|
||||||
<div class="login-error"><?=htmlspecialchars($errors['login'])?></div>
|
<div class="form-error"><?=htmlspecialchars($errors['login'])?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<form class="form-horizontal" action="index.php" method="post">
|
<form class="form-horizontal" action="index.php" method="post">
|
||||||
<input type="hidden" name="controller" value="Auth">
|
<input type="hidden" name="controller" value="Auth">
|
||||||
@ -11,7 +11,7 @@
|
|||||||
<input class="input-email" type="email" name="email" id="email" placeholder="E-Mail" required>
|
<input class="input-email" type="email" name="email" id="email" placeholder="E-Mail" required>
|
||||||
<label for="password">Passwort</label>
|
<label for="password">Passwort</label>
|
||||||
<input class="input-passwort" type="password" name="password" id="password" placeholder="Passwort" required>
|
<input class="input-passwort" type="password" name="password" id="password" placeholder="Passwort" required>
|
||||||
<button class="button-loggin" type="submit">Login</button>
|
<button class="button-login" type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
<div style="text-align:center; margin-top: 1.5em;">
|
<div style="text-align:center; margin-top: 1.5em;">
|
||||||
<a class="link-passwort-vergessen" href="?controller=Auth&do=showForgotPasswordForm">Passwort vergessen?</a>
|
<a class="link-passwort-vergessen" href="?controller=Auth&do=showForgotPasswordForm">Passwort vergessen?</a>
|
||||||
|
@ -1,64 +1,37 @@
|
|||||||
<div class="inhalt">
|
<div class="inhalt">
|
||||||
<div class="login-container">
|
<div class="form-container">
|
||||||
<h1>Registrieren</h1>
|
<h1>Registrieren</h1>
|
||||||
<form class="form-horizontal" action="#" method="post">
|
<?php if (!empty($errors['register'])): ?>
|
||||||
<label>
|
<div class="form-error"><?=htmlspecialchars($errors['register'])?></div>
|
||||||
<input class="input-vorname" type="text" placeholder="Vorname">
|
<?php endif; ?>
|
||||||
</label>
|
<form class="form-horizontal" action="index.php" method="post">
|
||||||
|
<input type="hidden" name="controller" value="Auth">
|
||||||
|
<input type="hidden" name="do" value="register">
|
||||||
|
<label for="first_name">Vorname</label>
|
||||||
|
<input class="input-vorname" type="text" name="first_name" id="first_name" placeholder="Vorname" required value="<?=htmlspecialchars($validData['first_name'] ?? '')?>">
|
||||||
|
<label for="last_name">Nachname</label>
|
||||||
|
<input class="input-nachname" type="text" name="last_name" id="last_name" placeholder="Nachname" required value="<?=htmlspecialchars($validData['last_name'] ?? '')?>">
|
||||||
|
<label for="email">E-Mail</label>
|
||||||
|
<input class="input-email" type="email" name="email" id="email" placeholder="E-Mail" required value="<?=htmlspecialchars($validData['email'] ?? '')?>">
|
||||||
|
<label for="password">Passwort</label>
|
||||||
|
<input class="input-passwort" type="password" name="password" id="password" placeholder="Passwort" required>
|
||||||
|
<label for="password_repeat">Passwort wiederholen</label>
|
||||||
|
<input class="input-passwort-repeat" type="password" name="password_repeat" id="password_repeat" placeholder="Passwort wiederholen" required>
|
||||||
|
<label for="street">Straße</label>
|
||||||
|
<input class="input-strasse" type="text" name="street" id="street" placeholder="Straße" required value="<?=htmlspecialchars($validData['street'] ?? '')?>">
|
||||||
|
<label for="house_number">Hausnr.</label>
|
||||||
|
<input class="input-hausnr" type="text" name="house_number" id="house_number" placeholder="Hausnr." required value="<?=htmlspecialchars($validData['house_number'] ?? '')?>">
|
||||||
|
<label for="postal_code">Postleitzahl</label>
|
||||||
|
<input class="input-postleitzahl" type="text" name="postal_code" id="postal_code" placeholder="Postleitzahl" required value="<?=htmlspecialchars($validData['postal_code'] ?? '')?>">
|
||||||
|
<label for="city">Ort</label>
|
||||||
|
<input class="input-ort" type="text" name="city" id="city" placeholder="Ort" required value="<?=htmlspecialchars($validData['city'] ?? '')?>">
|
||||||
|
<label for="country">Land</label>
|
||||||
|
<input class="input-land" type="text" name="country" id="country" placeholder="Land" required value="<?=htmlspecialchars($validData['country'] ?? '')?>">
|
||||||
|
<label for="phone">Telefonnr.</label>
|
||||||
|
<input class="input-tel" type="text" name="phone" id="phone" placeholder="Telefonnr." required value="<?=htmlspecialchars($validData['phone'] ?? '')?>">
|
||||||
|
<button class="button-register" type="submit">Registrieren</button>
|
||||||
</form>
|
</form>
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-nachname" type="text" placeholder="Nachname">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-email" type="text" placeholder="E-Mail">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-passwort" type="text" placeholder="Passwort">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-passwort-repeat" type="text" placeholder="Passwort wiederholen">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-strasse" type="text" placeholder="Straße">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-hausnr" type="text" placeholder="Hausnr.">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-postleitzahl" type="text" placeholder="Postleitzahl">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-ort" type="text" placeholder="Ort">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-land" type="text" placeholder="Land">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<form class="form-horizontal" action="#" method="post">
|
|
||||||
<label>
|
|
||||||
<input class="input-tel" type="text" placeholder="Telefonnr.">
|
|
||||||
</label>
|
|
||||||
</form>
|
|
||||||
<button class="button-register">Registrieren</button>
|
|
||||||
<a class="link-konto-erstellen" href="?controller=Auth&do=showLoginForm">Login</a>
|
<a class="link-konto-erstellen" href="?controller=Auth&do=showLoginForm">Login</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
14
Views/Auth/showRegistrationSuccess.phtml
Normal file
14
Views/Auth/showRegistrationSuccess.phtml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<div class="inhalt">
|
||||||
|
<div class="login-success">
|
||||||
|
<h2>Registrierung erfolgreich!</h2>
|
||||||
|
<p>Sie werden in wenigen Sekunden zum Login weitergeleitet...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location.href = "?controller=Auth&do=showLoginForm";
|
||||||
|
}, 2000);
|
||||||
|
</script>
|
||||||
|
<noscript>
|
||||||
|
<meta http-equiv="refresh" content="2;url=?controller=Auth&do=showLoginForm">
|
||||||
|
</noscript>
|
@ -12,15 +12,15 @@
|
|||||||
<div id="logo" ><a class="link-logo" href="#"></a></div>
|
<div id="logo" ><a class="link-logo" href="#"></a></div>
|
||||||
<button id="nav-toggle-btn" aria-label="Menü ein-/ausklappen">▼</button>
|
<button id="nav-toggle-btn" aria-label="Menü ein-/ausklappen">▼</button>
|
||||||
<div class="nav-links">
|
<div class="nav-links">
|
||||||
<a id="link-tickets" class="links" href="?controller=Event&do=showEvents">Event</a>
|
|
||||||
<a id="link-infos" class="links" href="?controller=Welcome&do=showWelcome">Infos</a>
|
|
||||||
<a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a>
|
|
||||||
<?php if (isset($_SESSION['user'])): ?>
|
<?php if (isset($_SESSION['user'])): ?>
|
||||||
|
<a id="link-tickets" class="links" href="?controller=Event&do=showEvents">Event</a>
|
||||||
|
<a id="link-infos" class="links" href="?controller=Welcome&do=showWelcome">Infos</a>
|
||||||
|
<a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a>
|
||||||
<a id="link-logout" class="links" href="?controller=Auth&do=logout">Logout</a>
|
<a id="link-logout" class="links" href="?controller=Auth&do=logout">Logout</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a>
|
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a>
|
||||||
|
<a id="link-register" class="links" href="?controller=Auth&do=showRegistrationForm">Register</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a id="link-register" class="links" href="?controller=Auth&do=showRegistrationForm">Register</a>
|
|
||||||
<div id="profile-picture"></div>
|
<div id="profile-picture"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user