-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
135 lines (127 loc) · 5.83 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
session_start();
include("connection.php");
// Check if the user is already logged in, if yes then redirect him to welcome page
if (isset($_SESSION["staff_id"])) {
if ($_SESSION['role_id'] == 1) {
echo "<script>window.location.href='QAM_Topics.php'</script>";
} else if ($_SESSION['role_id'] == 2) {
echo "<script>window.location.href='QAC_Staff.php'</script>";
} else if ($_SESSION['role_id'] == 3) {
echo "<script>window.location.href='Staff.php'</script>";
} else {
echo "<script>window.location.href='index.php'</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="mswebdialog-title" content="Connecting to University of Greenwich">
<!-- Display image title -->
<link rel="icon" type="image/png" href="./img/favicon.ico">
<link rel="stylesheet" type="text/css" href="./css/login.css">
<style>
.illustrationClass {
background-image: url(./img/illustration.jpg)
}
</style>
<title>University of Greenwich - Ideas Portal</title>
</head>
<body>
<div id="fullPage">
<div id="brandingWrapper" class="float">
<div id="branding" class="illustrationClass">
<div id="brandingTint"></div>
</div>
</div>
<div id="contentWrapper" class="float">
<div id="content">
<div id="header">
<img class="logoImage" id="companyLogo" src="./img/logo.png" alt="University of Greenwich">
</div>
<main>
<div id="workArea">
<div id="authArea" class="groupMargin">
<div id="loginArea">
<div id="loginMessage" class="groupMargin">Sign in</div>
<form method="post" id="loginForm" autocomplete="off" novalidate="novalidate" action="">
<div id="error" class="fieldMargin error smallText" style="display: none;">
<span id="errorText" for="" aria-live="assertive" role="alert"></span>
</div>
<div id="formsAuthenticationArea">
<div id="userNameArea" style="display: block;">
<label id="userNameInputLabel" for="userNameInput" class="hidden">User
Account</label>
<input id="EmailInput" name="email" type="email" value="" tabindex="1"
class="text fullWidth" spellcheck="false"
placeholder="[email protected]" autocomplete="off">
</div>
<div id="passwordArea" style="display: block;">
<label id="passwordInputLabel" for="passwordInput"
class="hidden">Password</label>
<input id="passwordInput" name="password" type="password" tabindex="2"
class="text fullWidth" placeholder="Password" autocomplete="off">
</div>
<div id="submissionArea" class="submitMargin">
<button type="submit" id="submitButton" class="submit" tabindex="4"
role="button">Sign in
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</main>
<div id="footerPlaceholder"></div>
</div>
<footer id="footer">
<div id="footerLinks" class="floatReverse">
<div>
<span id="copyright">Privacy • Terms • Ideas Uni © 2024</span>
<a id="home" class="pageLink footerLink " href="#">Home</a>
<a id="privacy" class="pageLink footerLink" href="#">Privacy & cookies</a>
<a id="helpDesk" class="pageLink footerLink" href="#">Need more help?</a>
</div>
</div>
</footer>
</div>
</div>
</body>
</html>
<?php
if (isset($_POST['email']) && isset($_POST['password'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$sql = "SELECT * FROM Staff WHERE Email = '$email'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
if (password_verify($password, $row['Password'])) {
$_SESSION['staff_id'] = $row['StaffID'];
$_SESSION['full_name'] = $row['FullName'];
$_SESSION['email'] = $row['Email'];
$_SESSION['role_id'] = $row['RoleID'];
$_SESSION['department_id'] = $row['DepartmentID'];
$_SESSION['login'] = true;
if (isset($_SESSION['staff_id'])) {
if ($_SESSION['role_id'] == 1) {
echo "<script>window.location.href='QAM_Topics.php'</script>";
} else if ($_SESSION['role_id'] == 2) {
echo "<script>window.location.href='QAC_Staff.php'</script>";
} else if ($_SESSION['role_id'] == 3) {
echo "<script>window.location.href='Staff.php'</script>";
} else {
echo "<script>window.location.href='index.php'</script>";
}
}
} else {
echo "<script>alert('Password or Username is incorrect')</script>";
}
} else {
echo "<script>alert('Password or Username is incorrect')</script>";
}
}
?>