-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
27 lines (24 loc) · 930 Bytes
/
delete.php
File metadata and controls
27 lines (24 loc) · 930 Bytes
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
<?php
include('ai.php');
if (isset($_POST['deleteemployee'])) {
$delete_id = $_POST['delete_id'];
// Check if ID exists in the database before deleting
$check_query = "SELECT * FROM employee WHERE Id = '$delete_id'";
$check_result = mysqli_query($connection, $check_query);
if (mysqli_num_rows($check_result) == 0) {
// ID does not exist
header('Location: name.php?message=ID does not exist');
exit();
} else {
// ID exists, show confirmation dialog using JavaScript
echo '<script>';
echo 'if (confirm("Are you sure you want to delete this record?")) {';
echo ' window.location = "delete_employee.php?delete_id=' . $delete_id . '";'; // Redirect to delete script
echo '} else {';
echo ' window.location = "name.php";'; // Redirect back to where you came from
echo '}';
echo '</script>';
exit();
}
}
?>