fix phps, js for bet limit, css for board (fixed git things)

This commit is contained in:
AloneInSky 2025-11-26 15:49:38 +07:00
parent 16184e5757
commit cdda26f7d4
7 changed files with 165 additions and 31 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.html
*.txt

View File

@ -27,7 +27,6 @@ body, html{
.container{
width:100%;
max-width:980px;
background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
border-radius:16px;
padding:20px;
@ -102,6 +101,10 @@ a{
margin-bottom:14px
}
.w80{
width: 80%;
}
table{
width:100%;
border-collapse:collapse;
@ -249,3 +252,20 @@ footer{
.plus, .minus {
margin-top: 0 !important;
}
.mb16 {
margin-bottom: 16px;
}
/* Chrome, Edge, Safari */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type="number"] {
-moz-appearance: textfield; /* old syntax */
appearance: textfield; /* standard property */
}

View File

@ -1,11 +1,27 @@
document.querySelector(".plus").addEventListener("click", () => {
const input = document.querySelector(".num-box input");
const step = Number(input.step) || 1;
input.value = Number(input.value) + step;
const step = Number(input.step) || 1000;
const max = Number(input.max);
let newValue = Number(input.value) + step;
if (!isNaN(max)) {https://git-eng.ukwms.ac.id/2526-web/Kelompok_13.git
newValue = Math.min(newValue, max);
}
input.value = newValue;
});
document.querySelector(".minus").addEventListener("click", () => {
const input = document.querySelector(".num-box input");
const step = Number(input.step) || 1;
input.value = Math.max(1000, Number(input.value) - step);
const step = Number(input.step) || 1000;
const min = Number(input.min);
let newValue = Number(input.value) - step;
if (!isNaN(min)) {
newValue = Math.max(newValue, min);
}
input.value = newValue;
});

View File

@ -1,3 +1,31 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once "../includes/config.php";
// Top 10 bets
$stmt = $conn->prepare("SELECT b.bet, u.username FROM bets b JOIN users u ON b.uid = u.uid ORDER BY b.bet DESC LIMIT 10;");
$stmt->execute();
$result = $stmt->get_result();
$bets = $result->fetch_all(MYSQLI_ASSOC);
$stmt->close();
// Top 10 wins
$stmt = $conn->prepare("SELECT b.win, u.username FROM wins b JOIN users u ON b.uid = u.uid ORDER BY b.win DESC LIMIT 10;");
$stmt->execute();
$result = $stmt->get_result();
$wins = $result->fetch_all(MYSQLI_ASSOC);
$stmt->close();
// Top 10 users by money
$stmt = $conn->prepare("SELECT * FROM users ORDER BY money DESC LIMIT 10");
$stmt->execute();
$result = $stmt->get_result();
$users = $result->fetch_all(MYSQLI_ASSOC);
$stmt->close();
?>
<!doctype html>
<html lang="id">
<head>
@ -6,19 +34,18 @@
<title>Hit and Run Leaderboard</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<body style="width: 100%;">
<div class="container w80">
<div class="header">
<div class="logo">🂡</div>
<div class="title">
<h2>Hit Or Run Leaderboard</h2>
<p>Daftar pemain terbaik dari meja Hit Or Run. Tema: felt table, kartu, dan nuansa kasino.</p>
</div>
</div>
<div class="board">
<div class="board mb16">
<div class="panel">
<h3>Top Players</h3>
<h3>Top Rich Mans</h3>
<div id="leaderboard-wrap">
<table id="leaderboard">
<thead>
@ -29,11 +56,65 @@
</tr>
</thead>
<tbody id="board-body">
<?php foreach ($users as $index => $user): ?>
<tr>
<td>1</td>
<td>Tepen</td>
<td>100</td>
<td><?= $index + 1 ?></td>
<td><?= htmlspecialchars($user['username']) ?></td>
<td><?= htmlspecialchars($user['money']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="board mb16">
<div class="panel">
<h3>Top Crazy Mans</h3>
<div id="leaderboard-wrap">
<table id="leaderboard">
<thead>
<tr>
<th class="rank">#</th>
<th>Player</th>
<th>Bets</th>
</tr>
</thead>
<tbody id="board-body">
<?php foreach ($bets as $index => $bet): ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?= htmlspecialchars($bet['username']) ?></td>
<td><?= htmlspecialchars($bet['bet']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="board mb16">
<div class="panel">
<h3>Top Lucky Mans</h3>
<div id="leaderboard-wrap">
<table id="leaderboard">
<thead>
<tr>
<th class="rank">#</th>
<th>Player</th>
<th>Earnings</th>
</tr>
</thead>
<tbody id="board-body">
<?php foreach ($wins as $index => $win): ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?= htmlspecialchars($win['username']) ?></td>
<td><?= htmlspecialchars($win['win']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>

View File

@ -1,15 +1,23 @@
<?php
require "../includes/config.php";
if (!isset($_SESSION["uid"])) {
header("Location: signin.php");
if (!isset($_SESSION["data"])) {
header("Location: signin");
exit;
}
// Get money
$stmt = $conn->prepare("SELECT money FROM users WHERE uid = ?");
$stmt->bind_param("i", $_SESSION['data']['uid']);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
$stmt->close();
// Update session
$_SESSION['data']['money'] = $user['money'];
?>
<a href="logout.php">Logout</a>
?>
<!doctype html>
<html lang="id">
<head>
@ -27,8 +35,8 @@
</div>
<div style="padding-top: 32px; display:flex; flex-direction:column; align-items:center;">
<div class="num-box">
<button class="btn minus"></button>
<input type="number" value="1000" style="margin-bottom: -1px;">
<button class="btn minus">-</button>
<input min="1000" max="<?php echo $_SESSION['data']['money']; ?>"type="number" value="1000" style="margin-bottom: -1px;">
<button class="btn plus">+</button>
</div>
<button class="btn btn-primary" id="playBtn">▶️ MAINKAN</button>
@ -40,8 +48,8 @@
<div class="avatar">P</div>
<div class="info">
<div class="name"><?php echo $_SESSION["username"]; ?></div>
<div class="saldo">Saldo: <span><?php echo $_SESSION["money"]; ?></span></div>
<div class="name"><?php echo $_SESSION['data']["username"]; ?></div>
<div class="saldo">Saldo: <span><?php echo $_SESSION['data']["money"]; ?></span></div>
<div class="status">Status: Masih Pemula Banghh....</div>
</div>
</div>

View File

@ -5,7 +5,7 @@
$username = trim($_POST["username"]);
$password = $_POST["password"];
$stmt = $conn->prepare("SELECT id, username, password FROM users WHERE username = ?");
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
@ -15,8 +15,8 @@
$user = $result->fetch_assoc();
if (password_verify($password, $user["password"])) {
$_SESSION["uid"] = $user["uid"];
header("Location: home.php");
$_SESSION["data"] = $user;
header("Location: home");
exit;
} else {
$error = "Wrong Username or Password.";

View File

@ -1,5 +1,9 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once "../includes/config.php";
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$username = trim($_POST["username"]);
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
@ -8,13 +12,17 @@
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
$stmt->bind_param("ss", $username, $password);
if ($stmt->execute()) {
echo "Account created! <a href='signin.php'>Login here</a>";
try {
$stmt->execute();
header("Location: signin.php");
exit;
} else {
echo "Username already exists.";
} catch (mysqli_sql_exception $e) {
if ($e->getCode() == 1062) {
$error = "Username already exists.";
}
}
}
?>
<!doctype html>