-
- Blackjack [21]
-
-
-
-
Signed in as:
-
-
Logout
-
-
-
-
-
-
-
-
-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
-
-
-
-
-
-
-
-
-
-
-
-
-
Pemain
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
×
-
💳 Top Up Saldo
-
-
-
Pemain:
-
Saldo Saat Ini: Rp 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/loginn.php b/loginn.php
index 7fc288b..63c613a 100644
--- a/loginn.php
+++ b/loginn.php
@@ -95,4 +95,22 @@ if(isset($_POST['register'])){
}
}
?>
-
\ No newline at end of file
+
+$sql = "SELECT id, username, password, bank FROM users WHERE username = ?";
+$stmt = mysqli_prepare($conn, $sql);
+mysqli_stmt_bind_param($stmt, "s", $username);
+mysqli_stmt_execute($stmt);
+$result = mysqli_stmt_get_result($stmt);
+
+if ($row = mysqli_fetch_assoc($result)) {
+
+ if ($password === $row['password']) {
+
+ $_SESSION['user_id'] = $row['id'];
+ $_SESSION['username'] = $row['username'];
+ $_SESSION['bank'] = intval($row['bank']); // ← INI YANG PENTING
+
+ header("Location: html.php");
+ exit;
+ }
+}
diff --git a/prosestopup.php b/prosestopup.php
deleted file mode 100644
index 6d7315b..0000000
--- a/prosestopup.php
+++ /dev/null
@@ -1,56 +0,0 @@
- false, 'message' => 'Not logged in']);
- exit;
-}
-
-if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $user_id = $_SESSION['user_id'];
- $amount = intval($_POST['amount']);
- $bank_method = $_POST['bank_method'] ?? 'unknown';
-
- // Validasi
- if ($amount <= 0 || $amount > 1000000) {
- echo json_encode(['success' => false, 'message' => 'Invalid amount']);
- exit;
- }
-
- // Update balance di database
- $sql = "UPDATE users SET balance = balance + ? WHERE id = ?";
- $stmt = mysqli_prepare($conn, $sql);
- mysqli_stmt_bind_param($stmt, "ii", $amount, $user_id);
-
- if (mysqli_stmt_execute($stmt)) {
- // Get new balance
- $sql2 = "SELECT balance FROM users WHERE id = ?";
- $stmt2 = mysqli_prepare($conn, $sql2);
- mysqli_stmt_bind_param($stmt2, "i", $user_id);
- mysqli_stmt_execute($stmt2);
- $result = mysqli_stmt_get_result($stmt2);
- $user = mysqli_fetch_assoc($result);
-
- // Update session
- $_SESSION['balance'] = $user['balance'];
-
- // Log transaction
- $log_sql = "INSERT INTO transactions (user_id, type, amount, description)
- VALUES (?, 'topup', ?, 'Top up via $bank_method')";
- $log_stmt = mysqli_prepare($conn, $log_sql);
- mysqli_stmt_bind_param($log_stmt, "ii", $user_id, $amount);
- mysqli_stmt_execute($log_stmt);
-
- echo json_encode([
- 'success' => true,
- 'new_balance' => $user['balance'],
- 'message' => 'Top up successful'
- ]);
- } else {
- echo json_encode(['success' => false, 'message' => 'Database error']);
- }
-}
-?>
\ No newline at end of file
diff --git a/topupnew.php b/topupnew.php
new file mode 100644
index 0000000..17ff851
--- /dev/null
+++ b/topupnew.php
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
Top Up Saldo - GameHub
+
+
+
+
+
+
💳 Top Up Saldo
+
+
+
Pemain: = htmlspecialchars($username) ?>
+
Saldo Saat Ini: Rp = number_format($currentBank, 0, ',', '.') ?>
+
+
+
+
+ = htmlspecialchars($message) ?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/upbalance.php b/upbalance.php
deleted file mode 100644
index c80285e..0000000
--- a/upbalance.php
+++ /dev/null
@@ -1,48 +0,0 @@
- false, 'message' => 'Not logged in']);
- exit;
-}
-
-$data = json_decode(file_get_contents('php://input'), true);
-$user_id = $_SESSION['user_id'];
-$balance = intval($data['balance']);
-
-// Update balance di database
-$sql = "UPDATE users SET balance = ? WHERE id = ?";
-$stmt = mysqli_prepare($conn, $sql);
-mysqli_stmt_bind_param($stmt, "ii", $balance, $user_id);
-
-if (mysqli_stmt_execute($stmt)) {
- // Update session
- $_SESSION['balance'] = $balance;
-
- // Log transaction jika perlu
- if (isset($data['transaction'])) {
- $transaction = $data['transaction'];
- $log_sql = "INSERT INTO transactions (user_id, type, amount, description)
- VALUES (?, ?, ?, ?)";
- $log_stmt = mysqli_prepare($conn, $log_sql);
- mysqli_stmt_bind_param($log_stmt, "ssis",
- $user_id,
- $transaction['type'],
- $transaction['amount'],
- $transaction['description']
- );
- mysqli_stmt_execute($log_stmt);
- }
-
- echo json_encode([
- 'success' => true,
- 'new_balance' => $balance,
- 'message' => 'Balance updated successfully'
- ]);
-} else {
- echo json_encode(['success' => false, 'message' => 'Database error']);
-}
-?>
\ No newline at end of file