<?php
include('koneksi.php');

$memberId = $_SESSION['UserID'] ?? null;

if ($memberId) {

    $sql = "SELECT * FROM members WHERE member_id = ?";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("i", $memberId);
    $stmt->execute();
    $result = $stmt->get_result();
    $member = $result->fetch_assoc();
    $stmt->close();

    $sqlmemb = "SELECT * FROM member_subscriptions WHERE member_id = ?";
    $stmt = $conn->prepare($sqlmemb);
    $stmt->bind_param("i", $memberId);
    $stmt->execute();
    $resultSub = $stmt->get_result();
    $memberSub = $resultSub->fetch_assoc();
    $stmt->close();

    $sqlpack = "SELECT * FROM membership_packages WHERE package_id = ?";
    $stmt = $conn->prepare($sqlpack);
    $stmt->bind_param("i", $memberSub['package_id']);
    $stmt->execute();
    $resultPack = $stmt->get_result();
    $memberPack = $resultPack->fetch_assoc();
    $stmt->close();    

} else {
    die("Member ID tidak valid");
}

?>
