session_start();
// If not logged in, redirect to login
if (!isset($_SESSION['username'])) {
header('Location: loginn.php');
exit;
}
// Initialize balance if not set
if (!isset($_SESSION['balance'])) {
$_SESSION['balance'] = 1000; // Default starting balance
}
// Handle Top Up form
$topup_response = '';
$topup_success = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['bank_method'])) {
$bank_method = $_POST['bank_method'] ?? '';
$amount = (int)($_POST['amount'] ?? 0);
if (empty($bank_method)) {
$topup_response = 'Pilih metode pembayaran terlebih dahulu.';
} elseif ($amount <= 0) {
$topup_response = 'Masukkan jumlah top up yang valid (lebih dari 0).';
} else {
$_SESSION['balance'] += $amount;
$topup_response = 'Top up berhasil! Saldo: Rp ' . number_format($_SESSION['balance'], 0, ',', '.');
$topup_success = true;
}
}
// Handle balance update from game
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_balance'])) {
$new_balance = (int)$_POST['update_balance'];
if ($new_balance >= 0) {
$_SESSION['balance'] = $new_balance;
header('Content-Type: application/json');
echo json_encode(['status' => 'success', 'balance' => $_SESSION['balance']]);
exit;
}
}
?>
Blackjack [21] - OCA GameHub
×
💳 Top Up Saldo
Pemain:
Saldo Saat Ini: Rp 0