AIPT/cms_admin/comment_status.php

32 lines
951 B
PHP
Raw Normal View History

2024-10-29 11:42:53 +08:00
<?php
// Include the database connection file
include('container/security.php');
// Get comment ID and status from URL parameters
$c_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$status = isset($_GET['status']) ? intval($_GET['status']) : 0;
// Check if valid ID and status are provided
if ($c_id > 0 && ($status == 0 || $status == 1)) {
// Update comment status
$qry = "UPDATE comment SET status = $status WHERE id = $c_id";
$run = mysqli_query($conn, $qry);
if ($run) {
// Display alert and redirect
echo "<script>
alert('Status updated successfully');
window.location.href = 'comments'; // Adjust to your comments list page
</script>";
exit;
} else {
echo "Error updating status: " . mysqli_error($conn);
}
} else {
echo "Invalid request.";
}
// Close the database connection
mysqli_close($conn);
?>