Upload files to "/"
This commit is contained in:
parent
e3e295e090
commit
cc7ba89209
@ -3,8 +3,8 @@ session_start();
|
|||||||
$conn = new mysqli("localhost","root","","breakout_db");
|
$conn = new mysqli("localhost","root","","breakout_db");
|
||||||
if($conn->connect_error){ die("DB Error"); }
|
if($conn->connect_error){ die("DB Error"); }
|
||||||
|
|
||||||
$isLoggedIn = isset($_SESSION['user']); // SUDAH DIPERBAIKI
|
$isLoggedIn = isset($_SESSION['user']);
|
||||||
$username = $isLoggedIn ? htmlspecialchars($_SESSION['user']) : null; // SUDAH DIPERBAIKI
|
$username = $isLoggedIn ? htmlspecialchars($_SESSION['user']) : null;
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|||||||
145
leaderboard.php
145
leaderboard.php
@ -1,57 +1,126 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
$conn = new mysqli("localhost","root","","breakout_db");
|
$conn = new mysqli("localhost", "root", "", "breakout_db");
|
||||||
$lb = $conn->query("SELECT username, highscore FROM users ORDER BY highscore DESC LIMIT 10");
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
$isLoggedIn = isset($_SESSION['user']); // SUDAH DIPERBAIKI
|
$lb_easy = $conn->query("SELECT username, highscore_easy FROM users WHERE highscore_easy > 0 ORDER BY highscore_easy DESC LIMIT 10");
|
||||||
$username = $isLoggedIn ? htmlspecialchars($_SESSION['user']) : null; // SUDAH DIPERBAIKI
|
|
||||||
|
$lb_medium = $conn->query("SELECT username, highscore_medium FROM users WHERE highscore_medium > 0 ORDER BY highscore_medium DESC LIMIT 10");
|
||||||
|
|
||||||
|
$lb_hard = $conn->query("SELECT username, highscore_hard FROM users WHERE highscore_hard > 0 ORDER BY highscore_hard DESC LIMIT 10");
|
||||||
|
|
||||||
|
$isLoggedIn = isset($_SESSION['user']);
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Leaderboard</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Leaderboard - Breakout Game</title>
|
||||||
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||||
|
|
||||||
<link rel="stylesheet" href="style.css">
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="leaderboard-body">
|
<body class="leaderboard-body">
|
||||||
|
|
||||||
<h2><i class="fas fa-trophy"></i> Leaderboard</h2>
|
<h2><i class="fas fa-trophy"></i> Hall of Fame</h2>
|
||||||
|
|
||||||
<<div class="menu">
|
<div class="menu">
|
||||||
<a href="index.php"><i class="fas fa-home"></i> Home</a>
|
<a href="index.php"><i class="fas fa-home"></i> Home</a>
|
||||||
|
|
||||||
<?php if($isLoggedIn): ?>
|
<?php if($isLoggedIn): ?>
|
||||||
<a href="logout.php"><i class="fas fa-right-from-bracket"></i> Logout</a>
|
<a href="logout.php"><i class="fas fa-right-from-bracket"></i> Logout</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="login.php"><i class="fas fa-sign-in-alt"></i> Login</a>
|
<a href="login.php"><i class="fas fa-sign-in-alt"></i> Login</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="board-container">
|
<div class="leaderboard-wrapper">
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Username</th>
|
|
||||||
<th>Highscore</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php while($r = $lb->fetch_assoc()) { ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= htmlspecialchars($r['username']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($r['highscore']) ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="index.php" class="back-button">⬅ Back</a>
|
<div class="lb-column">
|
||||||
|
<h3 class="easy-title">Easy Level</h3>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Score</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
if ($lb_easy->num_rows > 0) {
|
||||||
|
while($r = $lb_easy->fetch_assoc()) {
|
||||||
|
echo "<tr>
|
||||||
|
<td>" . htmlspecialchars($r['username']) . "</td>
|
||||||
|
<td>" . htmlspecialchars($r['highscore_easy']) . "</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<tr><td colspan='2' style='text-align:center;'>No records yet</td></tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="lb-column">
|
||||||
|
<h3 class="medium-title">Medium Level</h3>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Score</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
if ($lb_medium->num_rows > 0) {
|
||||||
|
while($r = $lb_medium->fetch_assoc()) {
|
||||||
|
echo "<tr>
|
||||||
|
<td>" . htmlspecialchars($r['username']) . "</td>
|
||||||
|
<td>" . htmlspecialchars($r['highscore_medium']) . "</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<tr><td colspan='2' style='text-align:center;'>No records yet</td></tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="lb-column">
|
||||||
|
<h3 class="hard-title">Hard Level</h3>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Score</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
if ($lb_hard->num_rows > 0) {
|
||||||
|
while($r = $lb_hard->fetch_assoc()) {
|
||||||
|
echo "<tr>
|
||||||
|
<td>" . htmlspecialchars($r['username']) . "</td>
|
||||||
|
<td>" . htmlspecialchars($r['highscore_hard']) . "</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<tr><td colspan='2' style='text-align:center;'>No records yet</td></tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<a href="index.php" class="back-button">⬅ Back to Game</a>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user