Create an insecure bank application
This commit is contained in:
44
webroot/lib/View/LoginPage.php
Normal file
44
webroot/lib/View/LoginPage.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace View;
|
||||
|
||||
class LoginPage extends BankingPage
|
||||
{
|
||||
public string $fieldUsername = '';
|
||||
public string $fieldPassword = '';
|
||||
public bool $formWasSent = false;
|
||||
|
||||
public bool $errorLoginDataInvalid = false;
|
||||
|
||||
public function __construct(...$args)
|
||||
{
|
||||
parent::__construct(...$args);
|
||||
if (isset($_POST['username'], $_POST['password'])) {
|
||||
$this->formWasSent = true;
|
||||
$this->fieldUsername = (string) $_POST['username'];
|
||||
$this->fieldPassword = (string) $_POST['password'];
|
||||
}
|
||||
}
|
||||
|
||||
public function sendTitle(): void
|
||||
{
|
||||
echo 'Einloggen';
|
||||
}
|
||||
|
||||
public function sendMainContent(): void
|
||||
{
|
||||
$username = htmlspecialchars($this->fieldUsername);
|
||||
$password = htmlspecialchars($this->fieldPassword);
|
||||
|
||||
echo '<h1>Einloggen</h1>';
|
||||
if ($this->errorLoginDataInvalid) {
|
||||
echo '<p class="error">[!] Der Login war nicht erfolgreich.</p>';
|
||||
}
|
||||
echo '<form class="login" action="/login.php" method="post">';
|
||||
echo "<label for=\"username\">Nutzername:</label><input type=\"text\" name=\"username\" id=\"username\" maxlength=\"20\" value=\"{$username}\"><br>";
|
||||
echo "<label for=\"password\">Passwort:</label><input type=\"password\" name=\"password\" id=\"password\" value=\"{$password}\"><br>";
|
||||
echo '<input type="submit" value="Einloggen">';
|
||||
echo '</form>';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user