-
Notifications
You must be signed in to change notification settings - Fork 0
/
employeeremove.php
executable file
·35 lines (32 loc) · 1.6 KB
/
employeeremove.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Marathon - Remove Employee</title>
</head>
<body>
<?php
session_start(); // Start a PHP session.
if ($_SESSION['authid'] == "marathon" and $_SESSION['loggedin'] == 1) { // Check to see if the user is logged in.
$username = $_SESSION['username']; // Set the '$username' variable to the currently signed in user's username.
} else {
header("Location: login.php"); // Redirect the user to the login page.
exit();
}
include("./import_databases.php");
$id_to_delete = $_GET["id"];
$confirmation = $_GET["confirmation"];
if ($confirmation !== "true") { // If the user hasn't yet pressed 'Confirm', the display the 'Confirm' button.
echo "<p>Confirm deletion</p>";
echo "<p><a href='employeeremove.php?id=" . $id_to_delete . "&confirmation=true'>Confirm</a></p>";
echo "<p><a href='employees.php'>Cancel</a></p>";
} else { // Otherwise, delete the employee.
unset($employee_database[$id_to_delete]); // Remove the employee from the employee database.
unset($timecard_database[$id_to_delete]); // Remove the employee from the timecard database.
save_database('employeedatabase.json', $employee_database); // Write array changes to disk.
save_database('timecarddatabase.json', $timecard_database); // Write array changes to disk.
echo "<p>Employee deleted</p>";
echo "<p><a href='employees.php'>Back</a></p>";
}
?>
</body>
</html>