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'])) { Blackjack [21] - OCA GameHub +
@@ -22,11 +265,11 @@ if (!isset($_SESSION['username'])) {
Signed in as:
- Top Up + Logout
-
-
Bank:
+
+
Bank: 0
Taruhan: 0
@@ -58,11 +301,174 @@ if (!isset($_SESSION['username'])) {
+ + +
OCA GameHub - Blackjack_[21] - Semoga menang bosq
+ diff --git a/loginn.php b/loginn.php index f0ff8c6..b1a2137 100644 --- a/loginn.php +++ b/loginn.php @@ -1,5 +1,7 @@ 0) { $user = mysqli_fetch_assoc($result); - session_start(); $_SESSION['username'] = $user['username']; - // ensure balance key exists - $_SESSION['balance'] = isset($user['balance']) ? (int)$user['balance'] : 0; + // Initialize balance in session (default 1000 if not set) + $_SESSION['balance'] = isset($user['balance']) ? (int)$user['balance'] : 1000; header("Location: html.php"); exit; } else { diff --git a/topup.php b/topup.php index e924af2..5b2a25a 100644 --- a/topup.php +++ b/topup.php @@ -1,5 +1,4 @@ 0) { - $row = mysqli_fetch_assoc($res); - $_SESSION['balance'] = (int)$row['balance']; -} if ($_SERVER['REQUEST_METHOD'] === 'POST') { $bank_method = isset($_POST['bank_method']) ? $_POST['bank_method'] : ''; @@ -29,31 +25,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $message = 'Pilih metode pembayaran terlebih dahulu.'; $message_type = 'error'; } else { - // Simulasi proses bank - $virtual_account = 'VA-' . strtoupper(substr($bank_method, 0, 3)) . '-' . substr($username, 0, 3) . '-' . rand(10000, 99999); - - // Update balance di database - $update = mysqli_query($conn, "UPDATE users SET balance = balance + $amount WHERE username = '$username'"); - if ($update) { - // Fetch saldo terbaru - $res = mysqli_query($conn, "SELECT balance FROM users WHERE username = '$username'"); - if ($res && mysqli_num_rows($res) > 0) { - $row = mysqli_fetch_assoc($res); - $_SESSION['balance'] = (int)$row['balance']; - $message = 'Top up berhasil! Saldo Anda: Rp ' . number_format($_SESSION['balance'], 0, ',', '.'); - $message_type = 'success'; - } else { - $message = 'Top up berhasil, tetapi gagal mengambil saldo terbaru.'; - $message_type = 'error'; - } - } else { - $message = 'Gagal memproses top up. Coba lagi.'; - $message_type = 'error'; - } + // Add balance to session + $_SESSION['balance'] += $amount; + $message = 'Top up berhasil! Saldo Anda: Rp ' . number_format($_SESSION['balance'], 0, ',', '.'); + $message_type = 'success'; } } ?> + @@ -266,6 +246,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { transition: all 0.3s ease; letter-spacing: 1px; flex: 1; + text-decoration: none; + display: flex; + align-items: center; + justify-content: center; } .btn-topup { @@ -304,7 +288,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
Saldo Saat Ini: - Rp + Rp
@@ -379,7 +363,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- Kembali + Kembali
@@ -389,6 +373,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { function setAmount(amount) { document.getElementById('amount').value = amount; } + + // Update balance display on page load + const serverBalance = ; + document.getElementById('topup-balance').textContent = 'Rp ' + serverBalance.toLocaleString('id-ID', { + minimumFractionDigits: 0, + maximumFractionDigits: 0 + }); + localStorage.setItem('playerBalance', serverBalance);