-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
85 lines (65 loc) · 2.04 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
session_start();
$pdo = new PDO('mysql:host=localhost;dbname=poplar', 'root', '');
if(isset($_GET['login'])) {
$benutzername = $_POST['benutzername'];
$password = sha1($_POST['password'] . 42);
$statement = $pdo->prepare("SELECT * FROM benutzer WHERE benutzername = :benutzername");
$result = $statement->execute(array('benutzername' => $benutzername));
$user = $statement->fetch();
$check = $pdo->prepare("SELECT * FROM benutzer WHERE password = :password");
$res = $check->execute(array('password' => $password));
$pass = $check->fetch();
//Überprüfung des Passworts
if ($user !== false && $pass !== false ) {
setcookie("bid",$user['BID'],0);
header("Location: http://localhost/fragen.php");
exit;
} else {
$errorMessage = "Benutzername oder Passwort war ungültig<br>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Poplar</title>
<meta charset="utf-8">
<meta content="Wie Tinder - Nur anders und besser!">
<link href="./pic_css/css.css" rel="stylesheet" type="text/css" media="all">
</head>
<body>
<ul class="topnav" id="myTopnav">
<li><a href="./login.php">Login</a></li> <li><a href="./reg.php">Registrieren</a></li>
</ul>
<div id="toplogo">
<a href="login.php"><img class="logo" src="./pic_css/poplarlogo.png" alt="Poplar" width="400"></a>
</div>
<div class="content" align="center">
<?php
if(isset($errorMessage)) {
echo $errorMessage;
}
?>
<form action="?login=1" method="post">
<p class="eingabe">Benutzername:</p>
<input type="text" size="40" maxlength="250" name="benutzername"><br><br>
<p class="eingabe">Dein Passwort:</p>
<input type="password" size="40" maxlength="250" name="password"><br>
<input type="submit" value="Abschicken">
</form>
</div>
<div id="footer" class="container">
</div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
</html>