tryhtml
This commit is contained in:
parent
9ccf44877a
commit
ae9cff9d8e
87
html.php
87
html.php
@ -8,6 +8,93 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AMBIL DATA TERBARU DARI DATABASE, jangan pakai session saja
|
||||||
|
$user_id = $_SESSION['user_id'];
|
||||||
|
$sql = "SELECT username, balance FROM users WHERE id = ?";
|
||||||
|
$stmt = mysqli_prepare($conn, $sql);
|
||||||
|
mysqli_stmt_bind_param($stmt, "i", $user_id);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
$user = mysqli_fetch_assoc($result);
|
||||||
|
|
||||||
|
// Update session dengan data terbaru dari database
|
||||||
|
$_SESSION['username'] = $user['username'];
|
||||||
|
$_SESSION['balance'] = intval($user['balance']);
|
||||||
|
|
||||||
|
$username = $_SESSION['username'];
|
||||||
|
$balance = $_SESSION['balance'];
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
<title>Blackjack [21] - OCA GameHub</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="cliff.css" />
|
||||||
|
<style>
|
||||||
|
/* ... semua CSS sebelumnya tetap ... */
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="table" role="application" aria-label="Blackjack tanpa iklan">
|
||||||
|
<header>
|
||||||
|
<h1> Blackjack [21] </h1>
|
||||||
|
<div class="controls">
|
||||||
|
<div style="display:flex;gap:12px;align-items:center;margin-bottom:8px;">
|
||||||
|
<div>Signed in as: <strong id="username-display"><?php echo htmlspecialchars($username); ?></strong></div>
|
||||||
|
<button id="topup-btn">Top Up</button>
|
||||||
|
<a href="logout.php" onclick="return confirm('Yakin ingin logout?')">Logout</a>
|
||||||
|
</div>
|
||||||
|
<div class="info">
|
||||||
|
<div class="chip">Bank: <span id="balance"><?php echo number_format($balance, 0, ',', '.'); ?></span></div>
|
||||||
|
<div class="chip">Taruhan: <span id="current-bet">0</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="bet">
|
||||||
|
<input id="bet-input" type="number" min="1" value="50" />
|
||||||
|
<button id="bet-btn">Pasang Taruhan</button>
|
||||||
|
<button id="new-round" class="secondary"> Reset </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<!-- ... game board tetap sama ... -->
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- Top Up Modal -->
|
||||||
|
<div id="topup-modal" class="modal" style="display: none;">
|
||||||
|
<!-- ... modal content tetap sama ... -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
OCA GameHub - <code> Blackjack_[21] - </code> Semoga menang bosq
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- SET GLOBAL VARIABLES DARI PHP -->
|
||||||
|
<script>
|
||||||
|
// Set global variables untuk JavaScript
|
||||||
|
window.serverBalance = <?php echo $balance; ?>;
|
||||||
|
window.userId = <?php echo $user_id; ?>;
|
||||||
|
window.username = "<?php echo addslashes($username); ?>";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="ody git.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include "koneksi.php";
|
||||||
|
|
||||||
|
// Redirect ke login jika belum login
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header("Location: loginn.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// Ambil data user dari database
|
// Ambil data user dari database
|
||||||
$user_id = $_SESSION['user_id'];
|
$user_id = $_SESSION['user_id'];
|
||||||
$sql = "SELECT username, balance FROM users WHERE id = ?";
|
$sql = "SELECT username, balance FROM users WHERE id = ?";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user