<?php

if (!isset($_SESSION['user_id']) || !isset($_SESSION['csrf_token'])) {
    $_SESSION['error'] = "Silahkan login terlebih dahulu";
    header("Location: /");
    exit();
}

$user_id = $_SESSION['user_id'];
$csrf_token = $_SESSION['csrf_token'];

$info_pengguna = "SELECT u.*, b1.*, b2.* 
                  FROM user u 
                  LEFT JOIN bank_user b1 ON u.id = b1.user_id 
                  LEFT JOIN balance b2 ON u.id = b2.user_id 
                  WHERE u.id = :user_id 
                  LIMIT 1";
$stmt = $db->prepare($info_pengguna);
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);

$extplayer = $user['extplayer'];
$saldo_aktif = isset($user['total_balance']) ? $user['total_balance'] : 0;
$saldo_putaran = isset($user['total_turnover']) ? $user['total_turnover'] : 0;

?>
