Repository navigation
Expand file tree
/
Copy pathmanage.php
More file actions
127 lines (102 loc) · 4.1 KB
/
Copy pathmanage.php
File metadata and controls
127 lines (102 loc) · 4.1 KB
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
<!--
// Unit/Assignment: COS10032 Comp Systems Project Assignment 3
// Author: Nicole Reichert
// Name : Manage.php
// Description: This is the managing page for the assignment and will display all rows of EOI by default.
// The user can specify the JobRefNo, LastName or FirstName to search by wildcard rule against the eoi
// table for the respective columns.
// This page is linked to from login.php when a user successfully logs in, and branches out into edit.php
// on editing the status (select) or the Edit link, or delete.php when clicked.
// Uses manage.inc.php to handle most verbose functions.
-->
<!DOCTYPE html>
<html lang='en'>
<!-- PHP -->
<?php
// Author: Nicole Reichert (100589839) for COS10032 Comp. Systems Project
// Assignment 2, PHP Forms (EOI). Team: Arvin Z, Matt C, Lachlan, Cale, Nicole
// INCLUDES
include "menu.inc.php";
include 'settings.php';
include 'functionsite.php';
include 'manage.inc.php';
// Keep PHP session
session_start();
// Draw HEAD and HEADER HTML
draw_headerhtml("Manage EOIs");
// We can ask if we have set the session from logging in ($_SESSION['account_loggedin'])
// if not, we can redirect them back to the login page.
// If the user is not logged in...
if ($_SESSION['account_loggedin'] != True) {
echo "Sorry, you are not logged in.";
header("location: login.php");
}
//error_reporting(E_ALL);
//ini_set('display_errors');
// INIT VARS
$jobRef = $firstName = $lastName = "";
$jobRefErr = $firstNameErr = $lastNameErr = $formErr = "";
$readyToTransact = False;
// Check if form was submitted and process the inputs
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get and sanitize form data
if (isset($_POST['jobRef'])) {
$jobRef = test_input($_POST['jobRef']);
}
if (isset($_POST['firstName'])) {
$firstName = test_input($_POST['firstName']);
}
if (isset($_POST['lastName'])) {
$lastName = test_input($_POST['lastName']);
}
// Build and execute query with form data
$result = $conn->query("SELECT * FROM `eoi` WHERE job_ref LIKE '%$jobRef%' AND first_name LIKE '%$firstName%' AND last_name LIKE '%$lastName%'");
} else {
// Default query to show all entries when page first loads
$result = $conn->query("SELECT * FROM `eoi`");
}
?>
<!-- PHP END -->
<body>
<main>
<section id="hero">
<!-- Print EOI results from an included function here -->
<section class="eoiresult">
<?php
// Print from EOI results..
print_eoi_results($result);
// Have we deleted an entry from delete.php?
if (http_response_code(302) && isset($_SERVER['HTTP_REFERER'])) {
if (preg_match("/delete.php/", $_SERVER['HTTP_REFERER'])) {
// GET referral will have action = delete and id of deleted user
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$id = $_GET['id'];
delete_notification($id);
}
}
}
?>
</section>
<aside>
<form class="submission" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" novalidate="novalidate" class="submission">
<h3>Search</h3>
<fieldset>
<label for="jobRef">Job Reference No.</label>
<input type="text" placeholder="Enter Job Reference No." id="jobRef" name="jobRef" required>
<p class="error"><?php echo $jobRefErr;?></p>
<label for="firstName">First Name</label>
<input type="text" placeholder="Enter First Name" id="firstName" name="firstName" required>
<p class="error"><?php echo $firstNameErr;?></p>
<label for="lastName">Last Name</label>
<input type="text" placeholder="Enter Last Name" id="lastName" name="lastName" required>
<p class="error"><?php echo $lastNameErr;?></p>
<button type="submit" class="video-link">Submit</button>
<p class="error"><?php echo $formErr;?></p>
</fieldset>
</form>
</aside>
</section>
</main>
<?php draw_footerhtml(); ?>
</body>
</html>