<?php
$error = $error ?? null;
$success = $success ?? null;
?>

<!--
    Form: Registrierung
    Funktion: Erstellung neuer Benutzerkonten
-->
<main class="login-page">
    <div class="login-container">

        <h1>Jetzt Registrieren!</h1>

        <?php if (!empty($error)): ?>
            <p class="alert-message is-error">
                <?php echo htmlspecialchars($error); ?>
            </p>
        <?php endif; ?>

        <?php if (!empty($success)): ?>
            <p class="alert-message is-success">
                <?php echo $success; ?>
            </p>
        <?php endif; ?>

        <form method="post" action="index.php?pfad=register">

            <p class="input-label">Email:</p>
            <input type="email"
                   name="email"
                   class="login-input"
                   placeholder="mustermann@web.de"
                   value="<?php echo htmlspecialchars($_POST["email"] ?? ""); ?>"
                   required>

            <p class="input-label">Vorname:</p>
            <input type="text"
                   name="vorname"
                   class="login-input"
                   placeholder="Max"
                   value="<?php echo htmlspecialchars($_POST["vorname"] ?? ""); ?>"
                   required>

            <p class="input-label">Nachname:</p>
            <input type="text"
                   name="nachname"
                   class="login-input"
                   placeholder="Mustermann"
                   value="<?php echo htmlspecialchars($_POST["nachname"] ?? ""); ?>"
                   required>

            <p class="input-label">Passwort:</p>
            <input type="password"
                   name="password"
                   class="login-input"
                   placeholder="Passwort"
                   required>

            <button type="submit"
                    value="register"
                    name="registerSubmit"
                    class="button">
                kostenlos registrieren
            </button>

        </form>

    </div>
</main>