<?php

require_once '../connect.php';

header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $userId = $_POST['userId'];
    $status = $_POST['status'];

    $query = "UPDATE member SET membership_status = :status WHERE userid = :userId";
    $stmt = $conn->prepare($query);

    try {
        $stmt->execute([
            ':status' => $status,
            ':userId' => $userId
        ]);
        echo json_encode(['success' => true]);
    } catch(PDOException $e) {
        echo json_encode(['success' => false, 'error' => $e->getMessage()]);
    }
}

?>
