-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·67 lines (66 loc) · 2.03 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
ob_start();
session_start();
require_once 'doeconnect.php';
if( isset($_POST['btn-login']) )
{
$username = $_POST['username'];
$pass = $_POST['password'];
$query = "SELECT Username,Password,AccountType FROM Users WHERE username = '$username'";
$result = mysqli_query($conn,$query);
if($result)
{
$row = mysqli_fetch_array($result);
$password = hash('sha256', $pass);
if( $row['Password'] == $password )
{
$_SESSION['username'] = $row['Username'];
if($row['AccountType'] == 'Admin')
{
header("Location: adminHome.php");
}
else if($row['AccountType'] == 'Merchant')
{
header("Location: merchantHome.php");
}
else
{
header("Location: home.php");
}
}
else
{
echo "Incorrect Password";
}
}
else
{
echo "Error : Query failed to execute";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="CSS/Form.css" type="text/css"/>
</head>
<body background="CSS/thumb-1920-840086.jpg">
<div class="login-page">
<div class="form">
<form class ="login-form" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">
<a class="message">LOGIN</a>
<br>
<br>
<input type="text" name="username" class="form-control" placeholder="Username" maxlength="64">
<br>
<input type="password" name="password" class="form-control" placeholder="Password" maxlength="64">
<button type="submit" class="btn btn-block btn-primary" name="btn-login">Login</button>
<br><br>
<a href="register.php">Not Registered? Sign Up Here</a>
</form>
</div>
</div>
</body>
</html>
<?php ob_end_flush(); ?>