AIPT/cms_admin/contact_delete.php

33 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2024-10-29 11:42:53 +08:00
<?php
// Include the database connection file
include('container/security.php');
if (isset($_GET['id'])) {
// Retrieve category ID from the URL
$id = intval($_GET['id']);
// Check if the ID is valid
if ($id > 0) {
// Prepare the SQL DELETE statements
$delete_category_sql = "DELETE FROM contacts WHERE id = $id";
// Execute the SQL statements
if (mysqli_query($conn, $delete_category_sql)) {
echo "<script>alert('Contat data deleted successfully.'); window.location.href = 'contact-form';</script>";
} else {
echo "<script>alert('Error: " . mysqli_error($conn) . "'); window.location.href = 'contact-form';</script>";
}
} else {
echo "<script>alert('Invalid category ID.'); window.location.href = 'contact-form';</script>";
}
} else {
echo "<script>alert('No category ID provided.'); window.location.href = 'contact-form';</script>";
}
// Close the database connection
mysqli_close($conn);
?>