-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
50 lines (47 loc) · 1.7 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
<?php
session_start();
include_once "Objects/User.php";
$errorMessage = "";
if(isset($_POST['login'])) {
$user = new User();
if ($user->isValidLogin($_POST['accountNumber'], $_POST['password'])) {
$_SESSION['loggedIn'] = true;
$_SESSION['userId'] = $_POST['accountNumber'];
$_SESSION['admin'] = $user->isAdmin($_POST['accountNumber']);
}
else {
$errorMessage = "Either the account number or password is incorrect";
};
}
if($_SESSION['loggedIn']) {
header("Location:index.php");
}
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>
<link rel="stylesheet" href="CSS/sharedStyles.css">
<link rel="stylesheet" href="CSS/formStyle.css">
</head>
<body>
<form class="border" method="post" action="login.php">
<a href="index.php"><img class="logo" src="images/logo.png" alt="Library of Time"></a>
<ul class="formList">
<li>
<input type="text" name="accountNumber" placeholder="Account Number *" size="30" autofocus required>
</li>
<li>
<input type="password" name="password" placeholder="Password *" minlength="6" size="30" required>
</li>
<span class="message"> <?= $errorMessage ?> </span>
<li>
<input type="submit" name="login" value="Login">
</li>
<a href="index.php">Home</a>
<br>
<a href="signup.php">Sign up</a>
</ul>
</form>
</body>
</html>