<?php
// Establish a database connection
$conn = mysqli_connect("localhost", "root", "sneaKer123@","sweatportal");

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Assuming you're passing the user ID and post ID in the request 
    $postId = $_POST['post_id'];

    // Update the status field to 1 for the specific user and post
    $sql = "UPDATE `sweat_video` SET `stats`='1' WHERE post_id = $postId";

    if (mysqli_query($conn, $sql)) {
        echo json_encode(['success' => true, 'message' => 'Status updated successfully']);
    } else {
        echo json_encode(['success' => false, 'message' => 'Error updating status']);
    }
} else {
    echo json_encode(['success' => false, 'message' => 'Invalid request method']);
}
?>
