-
Notifications
You must be signed in to change notification settings - Fork 38
/
login.php
37 lines (28 loc) · 1.24 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
<?php
require_once 'connect.php';
require_once 'header.php';
echo '<h2 class="w3-container w3-teal">Login</h2>';
if (isset($_POST['log'])) {
$username = mysqli_real_escape_string($dbcon, $_POST['username']);
$password = mysqli_real_escape_string($dbcon, $_POST['password']);
$sql = "SELECT * FROM admin WHERE username = '$username'";
$result = mysqli_query($dbcon, $sql);
$row = mysqli_fetch_assoc($result);
$row_count = mysqli_num_rows($result);
if ($row_count == 1 && password_verify($password, $row['password'])) {
$_SESSION['username'] = $username;
header("location: admin.php");
} else {
echo "<div class='w3-panel w3-pale-red w3-display-container'>Incorrect username or password.</div>";
}
}
?>
<form action="" method="POST" class="w3-container w3-padding">
<label>Username </label>
<input type="text" name="username" value="<?php if(isset($_POST['username'])){ echo strip_tags($_POST['username']);}?>" class="w3-input w3-border">
<label>Password</label>
<input type="password" name="password" class="w3-input w3-border">
<p><input type="submit" name="log" value="Login" class="w3-btn w3-teal"></p>
</form>
<?php
Include("footer.php");