forked from Anderson-Juhasc/bitcoin-point-of-sale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
66 lines (51 loc) · 1.71 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
<?php include 'partials/header.php'; ?>
<?php if ($_POST) : ?>
<?php
$user = $_POST['user'];
$password = md5($_POST['password']);
$db = new Db();
$user = $db->query("SELECT * FROM users WHERE user_name = :user LIMIT 1", array("user"=>"$user"));
if (count($user) == 1) {
if ($password == $user[0]["user_password"]) {
session_start();
$_SESSION['auth'] = 1;
$_SESSION['user_type'] = $user[0]["user_type"];
$_SESSION['user_id'] = $user[0]["user_id"];
header('Location: create.php');
}
}
if ($_SESSION['auth'] != 1) {
unset($_SESSION['auth']);
header('Location: ' . $_SERVER["PHP_SELF"]);
}
?>
<?php else : ?>
<?php
if ($_SESSION['auth'] == 1) {
header('Location: create.php');
}
?>
<!-- .wrapper -->
<div class="wrapper">
<!-- .page -->
<div class="page">
<!-- .page__head -->
<header class="page__head">
<h2 class="page__title">Dashboard</h2>
</header>
<!-- /.page__head -->
<!-- .page__body -->
<div class="page__body">
<form action="<?php $_SERVER["PHP_SELF"] ?>" method="POST">
User: <br><input type="text" name="user" class="input"><br><br>
Password: <br><input type="password" name="password" class="input"><br><br>
<button class="fields-action__btn btn btn--secondary btn--medium" type="submit">Login</button><br><br>
</form>
</div>
<!-- /.page__body -->
</div>
<!-- /.page -->
</div>
<!-- /.wrapper -->
<?php endif; ?>
<?php include 'partials/footer.php'; ?>