-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_employee.php
51 lines (38 loc) · 1.14 KB
/
delete_employee.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
<?php
//delete button
include 'conn.php';
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['delete'])) {
// Get employee ID from hidden input field
$employee_id = $_POST['employee_id'];
// Delete employee details from database
$sql = "DELETE FROM employee_details WHERE employee_id = '$employee_id'";
$result = mysqli_query($con, $sql);
if ($result) {
echo "Employee details deleted successfully";
}
else {
echo "Error deleting employee details: " . mysqli_error($con);
}
}
else {
echo "Invalid request";
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Delete Employee Details</title>
</head>
<body>
<h2>Delete Employee Details</h2>
<p>Are you sure you want to delete this employee's details?</p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<input type="hidden" name="employee_id" value="<?php echo $employee_id; ?>" />
<input type="submit" name="delete" value="Yes" />
<button onclick="window.history.back()">No</button>
</form>
</body>
</html>
<?php