-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo-login.php
More file actions
66 lines (47 loc) · 1.35 KB
/
Copy pathdo-login.php
File metadata and controls
66 lines (47 loc) · 1.35 KB
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
<?php
session_start();
if ((isset($_POST['username'])) && (isset($_POST['password'])))
{
/* An dieser Stelle Gültigkeit der übergebenen Strings prüfen */
if ((trim($_POST['username']) == '') || (trim($_POST['password']) == ''))
{
echo "Authentication failed, redirecting...";
session_destroy();
echo '<meta http-equiv="refresh" content="2; url=../login.php">';
exit;
}
require("../config.php");
$stmt = $dbconnect->prepare("SELECT id, password FROM sl_user WHERE username=?");
$stmt->bind_param("s", $_POST['username']);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 1)
{
$row = mysqli_fetch_assoc($result);
if (password_verify($_POST['password'], $row['password']))
{
echo "Authentication successfully, redirecting...";
$_SESSION['username'] = $_POST['username'];
echo '<meta http-equiv="refresh" content="2; url=../../index.php">';
}
else
{
echo "Authentication failed, redirecting...";
session_destroy();
echo '<meta http-equiv="refresh" content="2; url=../login.php">';
}
}
else
{
echo "Authentication failed, redirecting...";
session_destroy();
echo '<meta http-equiv="refresh" content="2; url=../login.php">';
}
}
else
{
echo "Authentication failed, redirecting...";
session_destroy();
echo '<meta http-equiv="refresh" content="2; url=../login.php">';
}
?>