<?php
include 'dbconnect.php'; // Your DB connection

if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['user_id'], $_POST['status'])) {
    $user_id = $_POST['user_id'];
    $status = $_POST['status'];
    $euser = "ADMIN"; // or use session user
    $edate = date("Y-m-d H:i:s");
    $flag=1;
    if($status=='Active'){
        $flag=0;
    }

     $sql = "UPDATE tbl_invite_user 
            SET status = '$status', edate = '$edate', euser = '$euser' , flag = '$flag'
            WHERE id = '$user_id'";

    if (mysqli_query($conn, $sql)) {
        echo "success";
    } else {
        http_response_code(500);
        echo "Database error.";
    }

    exit;
}
?>
