MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.68
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/localapp/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/localapp/admin/update_status.php
<?php
session_start();
include("inc/config.php"); // Include your database connection file

if (isset($_POST['update_status'])) {
    $news_id = $_POST['news_id'];

    // Fetch the current status
    $query = "SELECT status FROM news WHERE id='$news_id'";
    $result = mysqli_query($conn, $query);
    $row = mysqli_fetch_assoc($result);
    $current_status = $row['status'];

    // Toggle the status
    $new_status = ($current_status == 'Pending') ? 'Approved' : 'Pending';

    // Update the status in the database
    $update_query = "UPDATE news SET status='$new_status' WHERE id='$news_id'";
    if (mysqli_query($conn, $update_query)) {
        $_SESSION['status'] = "Status Updated Successfully";
    } else {
        $_SESSION['status'] = "Error Updating Status: " . mysqli_error($conn);
    }

    header("Location: view-news.php"); // Redirect back to the news page
    exit();
}
?>

MMCT - 2023