-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
99 lines (91 loc) · 3.55 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
<!DOCTYPE html>
<html>
<head>
<title>Employee Portal | Home</title>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<?php include "php/functions.php"; ?>
<div id="home">
<?php
session_start();
if (!isLoggedIn()) {
header("Location: login/index.php");
}
?>
<header>
<h1>Employee Portal | <?php print $_SESSION["firstName"] . " " . $_SESSION["lastName"] . " (" . getEmployeeType() . ")"; ?></h1>
<nav>
<a href="" class="currentPage">Home</a>
<a href="courses/">Courses</a>
<a href="profile/">Profile</a>
<a href="logout.php">Logout</a>
</nav>
</header>
<div id="content" class="clear">
<form action="" method="POST" id="searchForm">
<input type="text" name="searchText" id="searchText" placeholder="Search Students" autofocus />
<select name="type">
<option value="Student.StudentID">Student ID</option>
<option value="Student.StudentFirstName">First Name</option>
<option value="Student.StudentLastName">Last Name</option>
<option value="Employee.EmployeeFirstName">Advisor First Name</option>
<option value="Employee.EmployeeLastName">Advisor Last Name</option>
</select>
<input type="submit" name="search" id="search" value="Search" />
</form>
<?php
if (isset($_POST["search"])) {
viewStudents(TRUE, $_POST["type"], $_POST["searchText"]);
} else {
viewStudents();
}
if (isset($_POST["updateGrade"])) {
updateGrade($_POST["grade"], $_GET["student"], $_GET["course"]);
unset($_POST["updateGrade"]);
}
if ($_SESSION["type"] != 2) {
?>
<a href="createStudent">Add</a>
<?php
}
?>
<?php
if ($_SESSION["type"] == 0) {
?>
<form action="" method="POST">
<select name="studentToDelete">
<option hidden>Select Student to Delete...</option>
<?php
// Prepare the SQL statement
$studentSQL = "SELECT
Student.StudentID,
Student.StudentFirstName,
Student.StudentLastName
FROM
Student";
$query = $GLOBALS["db"]->query($studentSQL);
if (!$query) {
print $GLOBALS["db"]->error;
}
while ($row = mysqli_fetch_assoc($query)) {
?>
<option value="<?= $row["StudentID"] ?>"><?= $row["StudentFirstName"] . " " . $row["StudentLastName"] . " (" . $row["StudentID"] . ")" ?></option>
<?php
}
?>
</select>
<input type="submit" name="deleteStudent" value="Delete Student" />
</form>
<?php
}
if (isset($_POST["deleteStudent"])) {
deleteStudent($_POST["studentToDelete"]);
}
?>
</div>
</div>
</body>
</html>