31 lines
812 B
PHP
31 lines
812 B
PHP
<?php
|
|
// Include the database connection file
|
|
include('container/security.php');
|
|
|
|
// Get comment ID from URL parameters
|
|
$c_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
|
|
|
// Check if valid ID is provided
|
|
if ($c_id > 0) {
|
|
// Delete the comment
|
|
$qry = "DELETE FROM comment WHERE id = $c_id";
|
|
$run = mysqli_query($conn, $qry);
|
|
|
|
if ($run) {
|
|
// Display alert and redirect
|
|
echo "<script>
|
|
alert('Comment deleted successfully');
|
|
window.location.href = 'comments'; // Adjust to your comments list page
|
|
</script>";
|
|
exit;
|
|
} else {
|
|
echo "Error deleting comment: " . mysqli_error($conn);
|
|
}
|
|
} else {
|
|
echo "Invalid request.";
|
|
}
|
|
|
|
// Close the database connection
|
|
mysqli_close($conn);
|
|
?>
|