Weitere Reviewänderungen
This commit is contained in:
+5
-29
@@ -1,33 +1,7 @@
|
||||
<?php
|
||||
require_once "includes/LocalUserDAO.php";
|
||||
include_once 'php/controller/register-controller.php';
|
||||
|
||||
$dao = new LocalUserDAO();
|
||||
$error = null;
|
||||
|
||||
/*
|
||||
Verarbeitung des Registrierungs-Formulars
|
||||
Funktion: Erstellt neuen Benutzer und speichert ihn im DAO + Session
|
||||
*/
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
$email = $_POST["email"];
|
||||
$vorname = $_POST["vorname"];
|
||||
$nachname = $_POST["nachname"];
|
||||
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
|
||||
|
||||
if ($dao->findUser($email)) {
|
||||
$error = "Diese E-Mail-Adresse ist bereits registriert.";
|
||||
} else {
|
||||
|
||||
$dao->addUser($email, $vorname . " " . $nachname, $password);
|
||||
|
||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
||||
$_SESSION["user_email"] = $email;
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$error = $error ?? null;
|
||||
?>
|
||||
|
||||
<!--
|
||||
@@ -40,7 +14,9 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
<h1>Jetzt Registrieren!</h1>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<p style="color:red;"><?php echo $error; ?></p>
|
||||
<p style="color:red;">
|
||||
<?php echo htmlspecialchars($error); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="index.php?pfad=register">
|
||||
|
||||
Reference in New Issue
Block a user