mirror of
https://github.com/janunger/rheinwerk-video-training.git
synced 2026-02-06 07:05:14 +01:00
Initiale Version
This commit is contained in:
22
Kapitel_5/Lektion_3/login/login.php
Executable file
22
Kapitel_5/Lektion_3/login/login.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php if (false): ?>
|
||||
<p>Die eingegebenen Zugangsdaten sind nicht korrekt.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="" method="post">
|
||||
<label for="benutzername">Benutzername</label>
|
||||
<input id="benutzername" name="benutzername" type="text"/><br>
|
||||
<label for="passwort">Passwort</label>
|
||||
<input id="passwort" name="passwort" type="password"/><br>
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
2
Kapitel_5/Lektion_3/login/logout.php
Executable file
2
Kapitel_5/Lektion_3/login/logout.php
Executable file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
|
||||
21
Kapitel_5/Lektion_3/login/privat.php
Executable file
21
Kapitel_5/Lektion_3/login/privat.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Geschützter Bereich</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Geschützter Bereich</h1>
|
||||
|
||||
<?php if (false): ?>
|
||||
<p>angemeldet als (Hier soll der Benutzername erscheinen)</p>
|
||||
<p>Weitere vertrauliche Inhalte ...</p>
|
||||
<p><a href="logout.php">Abmelden</a></p>
|
||||
<?php else: ?>
|
||||
<p>Zugriff nur für angemeldete Benutzer</p>
|
||||
<p><a href="login.php">Zur Anmeldung</a></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
39
Kapitel_5/Lektion_3/login_loesung/login.php
Executable file
39
Kapitel_5/Lektion_3/login_loesung/login.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$istEingabeFehlerhaft = false;
|
||||
|
||||
if (isset($_POST['benutzername'])) {
|
||||
if ($_POST['benutzername'] == 'max.muster' && $_POST['passwort'] == 'geheim') {
|
||||
$_SESSION['benutzername'] = 'max.muster';
|
||||
header('Location: privat.php');
|
||||
exit;
|
||||
} else {
|
||||
$istEingabeFehlerhaft = true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php if ($istEingabeFehlerhaft): ?>
|
||||
<p>Die eingegebenen Zugangsdaten sind nicht korrekt.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="" method="post">
|
||||
<label for="benutzername">Benutzername</label>
|
||||
<input id="benutzername" name="benutzername" type="text"/><br>
|
||||
<label for="passwort">Passwort</label>
|
||||
<input id="passwort" name="passwort" type="password"/><br>
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
8
Kapitel_5/Lektion_3/login_loesung/logout.php
Executable file
8
Kapitel_5/Lektion_3/login_loesung/logout.php
Executable file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
unset($_SESSION['benutzername']);
|
||||
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
34
Kapitel_5/Lektion_3/login_loesung/privat.php
Executable file
34
Kapitel_5/Lektion_3/login_loesung/privat.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
$istBenutzerAngemeldet = isset($_SESSION['benutzername']);
|
||||
|
||||
if ($istBenutzerAngemeldet) {
|
||||
$benutzername = $_SESSION['benutzername'];
|
||||
} else {
|
||||
$benutzername = '';
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Geschützter Bereich</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Geschützter Bereich</h1>
|
||||
|
||||
<?php if ($istBenutzerAngemeldet): ?>
|
||||
<p>angemeldet als <?= htmlspecialchars($benutzername); ?></p>
|
||||
<p>Weitere vertrauliche Inhalte ...</p>
|
||||
<p><a href="logout.php">Abmelden</a></p>
|
||||
<?php else: ?>
|
||||
<p>Zugriff nur für angemeldete Benutzer</p>
|
||||
<p><a href="login.php">Zur Anmeldung</a></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user