<?php
session_start();
require_once __DIR__ . "/../config.php";

$email = $_SESSION["email"] ?? "";

$stmt = $conn->prepare("
    SELECT license_key, plan, active, expires_at, mt5_account
    FROM fxh_licenses
    WHERE user_email = ?
    ORDER BY id DESC
");

$stmt->bind_param("s",$email);
$stmt->execute();
$res = $stmt->get_result();

$licenses = [];

while($row = $res->fetch_assoc()){
    $licenses[] = $row;
}

header("Content-Type: application/json");
echo json_encode($licenses);
