Reviewnacharbeitung
This commit is contained in:
@@ -12,7 +12,7 @@ $error = $error ?? null;
|
|||||||
<h1>Jetzt Registrieren!</h1>
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
<?php if (!empty($error)): ?>
|
<?php if (!empty($error)): ?>
|
||||||
<p class="alert-message is-error">
|
<p class="alert-message is-error" style="color:red;">
|
||||||
<?php echo htmlspecialchars($error); ?>
|
<?php echo htmlspecialchars($error); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -1,43 +1,63 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$error = $error ?? null;
|
||||||
|
?>
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
<!--
|
||||||
require_once "php/validator/user-validator.php";
|
Form: Registrierung
|
||||||
|
Funktion: Erstellung neuer Benutzerkonten
|
||||||
|
-->
|
||||||
|
<main class="login-page">
|
||||||
|
<div class="login-container">
|
||||||
|
|
||||||
$error = null;
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
<?php if (!empty($error)): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
<?php echo htmlspecialchars($error); ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
$email = trim($_POST["email"] ?? "");
|
<form method="post" action="index.php?pfad=register">
|
||||||
$vorname = trim($_POST["vorname"] ?? "");
|
|
||||||
$nachname = trim($_POST["nachname"] ?? "");
|
|
||||||
$plainPassword = $_POST["password"] ?? "";
|
|
||||||
|
|
||||||
if (!userEmailValidator($email)) {
|
<p class="input-label">Email:</p>
|
||||||
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
<input type="email"
|
||||||
} elseif (!userNameValidator($vorname)) {
|
name="email"
|
||||||
$error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
class="login-input"
|
||||||
} elseif (!userNameValidator($nachname)) {
|
placeholder="mustermann@web.de"
|
||||||
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
value="<?php echo htmlspecialchars($_POST["email"] ?? ""); ?>"
|
||||||
} elseif (!userPasswordValidator($plainPassword)) {
|
required>
|
||||||
$error = "Das Passwort muss 8 bis 72 Zeichen lang sein.";
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
|
|
||||||
$password = password_hash($plainPassword, PASSWORD_DEFAULT);
|
<p class="input-label">Vorname:</p>
|
||||||
|
<input type="text"
|
||||||
|
name="vorname"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Max"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["vorname"] ?? ""); ?>"
|
||||||
|
required>
|
||||||
|
|
||||||
$dao->addUser($email, $vorname, $nachname, $password);
|
<p class="input-label">Nachname:</p>
|
||||||
|
<input type="text"
|
||||||
|
name="nachname"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Mustermann"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["nachname"] ?? ""); ?>"
|
||||||
|
required>
|
||||||
|
|
||||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
<p class="input-label">Passwort:</p>
|
||||||
$_SESSION["user_email"] = $email;
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Passwort"
|
||||||
|
required>
|
||||||
|
|
||||||
header("Location: index.php");
|
<button type="submit"
|
||||||
exit();
|
value="register"
|
||||||
|
name="registerSubmit"
|
||||||
|
class="login-button">
|
||||||
|
kostenlos registrieren
|
||||||
|
</button>
|
||||||
|
|
||||||
} catch (InvalidArgumentException $e) {
|
</form>
|
||||||
$error = $e->getMessage();
|
|
||||||
} catch (Exception $e) {
|
</div>
|
||||||
$error = "Die Registrierung konnte nicht gespeichert werden.";
|
</main>
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user