-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
93 lines (68 loc) · 3.01 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
86
87
88
89
90
91
92
93
<?php
require_once('connection/connection.php');
session_start();
if (!empty($_SESSION['username'])) {
header('location:index.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include('includes/header.php'); ?>
<body>
<main>
<!-- Top Bar -->
<nav class="navbar navbar-expand navbar-dark bg-dark" aria-label="First navbar example">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="navbarsExample01">
<ul class="navbar-nav me-auto mb-2">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="index.php">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="signup.php">Create Account</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row mb-3">
<div class="col-md-12 mt-5">
<div class="col-md-4 form-signin">
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
<?php
if (isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * from login WHERE username='" . $password . "' && password='" . $password . "'";
$result = $con->query($query)->fetch();
if ($result) {
if ($result['username'] == $_POST['username'] && $result['password'] == $_POST['password']) {
$_SESSION['username'] = $result['username'];
header('location:index.php');
}
} else {
echo "error";
}
}
?>
<form method="post">
<div class="form-group mb-3">
<label>Username</label>
<input type="text" name="username" class="form-control" required>
</div>
<div class="form-group mb-3">
<label>Password</label>
<input type="password" name="password" class="form-control" required>
</div>
<div class="form-group mb-3">
<input type="submit" class="btn btn-success btn-lg" value="Log In" name="login">
</div>
</form>
</div>
</div>
</div>
</div>
</main>
</body>
</html>