Compare commits

..

No commits in common. "6c0d77d4965c7102b4432c2a807ee6950d1808c4" and "cb96761ae800510f9d394439962537f8eb2c96ca" have entirely different histories.

5 changed files with 27 additions and 127 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

View File

@ -5,6 +5,15 @@ if (!isset($_SESSION['username'])) {
exit;
}
?>
<html>
<head>
<title>Sudoku</title>
<style>
/*CSS kamu tetap sama*/
</style>
</head>
<body>
<html>
<head>
<title>Sudoku</title>
@ -23,15 +32,17 @@ if (!isset($_SESSION['username'])) {
}
body {
font-family: 'Roboto', 'Segoe UI', sans-serif;
background: url("Background.jpg") no-repeat center center fixed;
background-size: cover;
color: var(--text-color);
margin: 0;
height: 100vh;
overflow: hidden;
}
font-family: 'Roboto', 'Segoe UI', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.screen {
display: none;
@ -41,7 +52,7 @@ if (!isset($_SESSION['username'])) {
width: 100%;
height: 100%;
position: absolute;
background-color: transparent;
background-color: var(--bg-color);
animation: fadeIn 0.3s ease-in-out;
}
@ -374,17 +385,12 @@ if (!isset($_SESSION['username'])) {
</head>
<body>
<div id="screen-menu" class="screen active">
<img src="Sudoku icon.jpg" alt="Logo" class="logo-img">
<div class="app-title">Sudoku</div>
<button class="btn-main" onclick="showLevelScreen()">Permainan Baru</button>
<button class="btn-main" onclick="window.location.href='leaderboard.php'">
Leaderboard
</button>
</div>
<div id="screen-menu" class="screen active">
<img src="Sudoku icon.jpg" alt="Logo" class="logo-img">
<div class="app-title">Sudoku</div>
<button class="btn-main" onclick="showLevelScreen()">Permainan Baru</button>
</div>
<div id="screen-level" class="screen">
<div class="level-title">Pilih Tingkat Kesulitan</div>
@ -724,7 +730,6 @@ if (!isset($_SESSION['username'])) {
}
stopTimer();
saveScore();
let diffText = document.getElementById('difficulty-label').innerText;
let timeText = document.getElementById("timer-label").innerText;
@ -792,15 +797,6 @@ if (!isset($_SESSION['username'])) {
if (b[i][j] != 0) { b[i][j] = 0; count--; }
}
}
function saveScore() {
fetch("save_score.php", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `difficulty=${currentDifficulty}&time=${secondsElapsed}`
});
}
</script>
</body>
</html>

View File

@ -1,74 +0,0 @@
<?php
require_once 'db.php';
// TES KONEKSI
if (!$conn) {
die("DB connection failed");
}
$sql = "
SELECT username, difficulty, time_seconds
FROM leaderboard_sudoku
ORDER BY difficulty, time_seconds ASC
LIMIT 10
";
$result = $conn->query($sql);
?>
<style>
.leaderboard {
background: #1e1e1e;
color: white;
padding: 20px;
border-radius: 10px;
width: 350px;
}
.leaderboard table {
width: 100%;
border-collapse: collapse;
}
.leaderboard th, .leaderboard td {
padding: 8px;
border-bottom: 1px solid #444;
text-align: center;
}
.leaderboard th {
background: #333;
}
</style>
<div class="leaderboard">
<h3>🏆 Leaderboard</h3>
<table>
<tr>
<th>User</th>
<th>Level</th>
<th>Time</th>
</tr>
<?php if ($result && $result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($row['username']) ?></td>
<td><?= strtoupper($row['difficulty']) ?></td>
<td>
<?= sprintf(
"%02d:%02d",
floor($row['time_seconds'] / 60),
$row['time_seconds'] % 60
) ?>
</td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<td colspan="3">Belum ada data</td>
</tr>
<?php endif; ?>
</table>
</div>
<?php $conn->close(); ?>

View File

@ -1,13 +0,0 @@
<?php
session_start();
require "koneksi.php"; // sesuaikan dengan file koneksi DB kamu
if (!isset($_SESSION['username'])) exit;
$username = $_SESSION['username'];
$difficulty = $_POST['difficulty'];
$time = intval($_POST['time']);
$stmt = $conn->prepare("INSERT INTO leaderboard_sudoku (username, difficulty, time_seconds) VALUES (?, ?, ?)");
$stmt->bind_param("ssi", $username, $difficulty, $time);
$stmt->execute();

View File

@ -63,15 +63,6 @@ ALTER TABLE `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
CREATE TABLE leaderboard_sudoku (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
difficulty VARCHAR(10),
time_seconds INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;