halohalo
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
u295559686
/
domains
/
stanjo.in
/
public_html
/
admin
/
status
/
Upload FileeE
HOME
<?php // Include your database connection include '../config.php'; // Enable error reporting for debugging ini_set('display_errors', 1); error_reporting(E_ALL); // Check if id and status are provided in the POST request if (isset($_POST['id']) && isset($_POST['status'])) { // Sanitize and assign variables from POST data $id = intval($_POST['id']); $status = $_POST['status']; // Handle both string and integer status values if ($status === 'active' || $status === '1' || $status === 1) { $status = 1; } elseif ($status === 'inactive' || $status === '0' || $status === 0) { $status = 0; } else { echo json_encode(['success' => false, 'message' => 'Invalid status value!']); exit; } // Prepare SQL query to update the status $query = "UPDATE supercategory SET status = ? WHERE id = ?"; $stmt = mysqli_prepare($conn, $query); mysqli_stmt_bind_param($stmt, 'ii', $status, $id); // Execute the query if (mysqli_stmt_execute($stmt)) { // Check if any rows were actually affected if (mysqli_stmt_affected_rows($stmt) > 0) { echo json_encode(['success' => true, 'message' => 'Status updated successfully!']); } else { echo json_encode(['success' => false, 'message' => 'No rows updated. Check if ID exists.']); } } else { echo json_encode(['success' => false, 'message' => 'Error executing query: ' . mysqli_error($conn)]); } mysqli_stmt_close($stmt); } else { echo json_encode(['success' => false, 'message' => 'Invalid request or missing data!']); } ?>