-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
50 lines (44 loc) · 2.02 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$meldung = "";
$email = "";
$passwort = "";
// $_SERVER['PHP_SELF'] = login.php in diesem Fall (also die PHP-Datei, die gerade ausgeführt wird).
// Mit andern Worten: Nach Senden des Formulars wird wieder login.php aufgerufen.
// Die Funktionen zur Überprüfung, ob die Login-Daten gültig sind, muss also hier oben im PHP-Teil stehen!
// Wenn Login-Daten korrekt sind:
// Session-Variable mit Benutzer-ID setzen und Wechsel in Memberbereich
// $_SESSION['uid'] = $uid;
// header('Location: index.php?function=entries_member');
// Wenn Formular gesendet worden ist, die Login-Daten aber nicht korrekt sind:
// Unten auf der Seite Anzeige der Fehlermeldung.
?>
<div id="login">
<h2 id="login_titel">Login</h2>
<?php
if(isset($_POST['email'])){
$userid = getUserIdFromDb($_POST['email'], $_POST['passwort']);
if($userid == 0){
echo "<p id='login_falsch'>Login nicht korrekt!</p>";
}else{
$_SESSION['userId']=$userid;
header("Location: {$_SERVER['PHP_SELF']}?function=mein_blog");
}
}
?>
<form id="loginform" method="post" action="<?php echo $_SERVER['PHP_SELF']."?function=login "; ?>">
<label for="email">Benutzername</label>
<div class="login_div">
<input class="login_imput" type="email" id="email" name="email" placeholder="E-Mail" value="" />
</div>
<label for="passwort">Passwort</label>
<div class="login_div">
<input class="login_imput" type="password" id="passwort" name="passwort" placeholder="Passwort" value="" />
</div>
<div>
<button id="login_button" type="submit">Login</button>
</div>
</form>
</div>
<a href="index.php?function=registrieren">
<button id="rigistrieren_button">Registrieren</button>
</a>