diff --git a/html.php b/html.php index 1c27870..184b4bc 100644 --- a/html.php +++ b/html.php @@ -5,6 +5,29 @@ 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; + } +} ?> @@ -14,6 +37,226 @@ if (!isset($_SESSION['username'])) {