-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelete_data.php
54 lines (39 loc) · 1.43 KB
/
delete_data.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
<?php
require "includes/db_connect.php";
require "includes/get_customer_data_id.php";
// connect to the database server
$conn = connectDB();
// READING or RETRIEVING from the database to get specific article post by their ids
if (isset($_GET['id'])){
// Delete the data in the database server by its id row
$sql = "DELETE FROM passengers_record WHERE id = ?";
// Prepares an SQL statement for execution
$stmt = mysqli_prepare($conn, $sql);
// Bind variables for the parameter markers in the SQL statement prepared
mysqli_stmt_bind_param($stmt, "i", $_GET["id"]);
// Executes a prepared statement
$result = mysqli_stmt_execute($stmt);
if($result){
// it is more advisable to use absolute paths below than relative path
header("Location: http://localhost/flight_booking-app/admin_page.php");
exit;
}
/* Check if the deletion was successful
if (mysqli_affected_rows($conn) > 0) {
echo "Data deleted successfully.";
} else {
echo "No data found or deletion failed.";
}
*/
} else{
echo "Invalid delete action. Page not found.";
}
// checks if the article's id exits in the database, then returns an associative array
$data = getCustomerData($conn, $_GET['id']);
if ($data){
// Get array values from its keys, which is used in the HTML form below
$id = $data['id'];
} else {
echo "No data found from such ID to be deleted.";
}
?>