-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
67 lines (55 loc) · 2.15 KB
/
index.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
<?php
include "includes/config.php";
include "includes/database.php";
include "includes/functions.php";
include "includes/header.php";
if (isset($_SESSION['id'])) {
header('Location: dashboard.php');
die();
}
if (isset($_POST['email'])) {
if ($stm = $connect->prepare('SELECT * FROM users WHERE email = ? AND password = ? AND active = 1')) {
$hashed = sha1($_POST['password']);
$stm->bind_param('ss', $_POST['email'], $hashed);
$stm->execute();
$result = $stm->get_result();
$user = $result->fetch_assoc();
if ($user) {
$_SESSION['id'] = $user['id'];
$_SESSION['email'] = $user['email'];
$_SESSION['username'] = $user['username'];
set_message("You are now logged in " . $_SESSION['username']);
header('Location: dashboard.php');
die();
}
$stm->close();
} else {
echo 'Could not prepare statement!';
}
}
?>
<div class="container mt-5" id="login-container">
<div class="row justify-content-center">
<div class="col-md-4">
<h2 class="display-6"><strong>Login</strong></h2>
<hr class="pb-3">
<form method="post">
<!-- Email input -->
<div class="form-outline login-form-outline mb-4">
<input type="email" id="email" name="email" class="form-control login-form-control" />
<label class="form-label login-form-label " for="email">Email address</label>
</div>
<!-- Password input -->
<div class="form-outline login-form-outline mb-4">
<input type="password" id="password" name="password" class="form-control login-form-control" />
<label class="form-label login-form-label " for="password">Password</label>
</div>
<!-- Submit button -->
<button type="submit" class="btn btn-primary btn-block login-btn">Sign in</button>
</form>
</div>
</div>
</div>
<?php
include "includes/footer.php";
?>