first commit
This commit is contained in:
31
cms_admin/comment_status.php
Normal file
31
cms_admin/comment_status.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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);
|
||||
?>
|
||||
Reference in New Issue
Block a user