<?php
require 'includes/db.php';
session_start();

if (!isset($_SESSION['user_id'])) {
    echo "error";
    exit;
}

$user_id = $_SESSION['user_id'];

$res = mysqli_query($conn,"
    SELECT status FROM billings 
    WHERE user_id='$user_id'
    ORDER BY id DESC LIMIT 1
");

$row = mysqli_fetch_assoc($res);

// ✅ CLEAN OUTPUT (VERY IMPORTANT)
echo trim($row['status'] ?? 'pending');