From 858676782dbfb0ac1fde74067163b619baaf64e5 Mon Sep 17 00:00:00 2001 From: Yustina Date: Mon, 15 Dec 2025 23:33:58 +0700 Subject: [PATCH] edit:update music + countdown --- auth.php | 69 ++++++++----- gameboard-hard.html | 234 +++++++++++++++++++++++++++++++++----------- index.php | 3 - 3 files changed, 219 insertions(+), 87 deletions(-) diff --git a/auth.php b/auth.php index 78e2417..416ee0e 100644 --- a/auth.php +++ b/auth.php @@ -20,54 +20,69 @@ if (isset($_POST['btn-register'])) { $password = $_POST['password']; $confirm = $_POST['confirm_password']; - // Validasi sederhana - if (empty($username) || empty($email) || empty($password) || empty($confirm)) { - $_SESSION['error'] = "Semua kolom wajib diisi!"; - header("Location: index.php"); + // --- VALIDASI DASAR --- + + if (!$username || !$email || !$password || !$confirm) { + // Balik ke index dengan pesan error + header("Location: index.php?register_error=Data tidak boleh kosong"); + exit; + } + + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + header("Location: index.php?register_error=Format email tidak valid"); + exit; + } + + if (strlen($password) < 6) { + header("Location: index.php?register_error=Password minimal 6 karakter"); exit; } if ($password !== $confirm) { - $_SESSION['error'] = "Konfirmasi password tidak cocok!"; - header("Location: index.php"); + header("Location: index.php?register_error=Konfirmasi password tidak cocok"); exit; } - // Cek user sudah ada atau belum + // --- CEK DATABASE (USER SUDAH ADA?) --- + $cek = $conn->prepare("SELECT id FROM users WHERE username=? OR email=?"); $cek->bind_param("ss", $username, $email); $cek->execute(); $cek->store_result(); if ($cek->num_rows > 0) { - $_SESSION['error'] = "Username atau Email sudah terdaftar!"; - header("Location: index.php"); + // INI YANG SEBELUMNYA MATI, SEKARANG REDIRECT: + header("Location: index.php?register_error=Username atau Email sudah terdaftar!"); exit; } $cek->close(); - - // Insert ke database + + // --- INSERT DATA BARU --- + $hash = password_hash($password, PASSWORD_DEFAULT); - $insert = $conn->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)"); + $insert = $conn->prepare("INSERT INTO users (username,email,password) VALUES (?,?,?)"); $insert->bind_param("sss", $username, $email, $hash); if ($insert->execute()) { - $_SESSION['success'] = "Registrasi berhasil! Silakan login."; + // Register Berhasil -> Arahkan ke Login (atau mainboard) + // Kita kosongkan error agar masuk ke state normal + header("Location: index.php"); + exit; } else { - $_SESSION['error'] = "Terjadi kesalahan sistem: " . $conn->error; + header("Location: index.php?register_error=Gagal mendaftar, coba lagi nanti."); + exit; } $insert->close(); - header("Location: index.php"); // Kembali ke index - exit; } /* ===================================================== LOGIN -===================================================== */ +==================================================== */ + if (isset($_POST['btn-login'])) { - $username = trim($_POST['username']); + $username = $_POST['username']; $password = $_POST['password']; $stmt = $conn->prepare("SELECT * FROM users WHERE username=?"); @@ -77,16 +92,16 @@ if (isset($_POST['btn-login'])) { $result = $stmt->get_result(); $user = $result->fetch_assoc(); - if ($user && password_verify($password, $user['password'])) { - // Login Sukses - $_SESSION['user'] = $user; - header("Location: mainboard.php"); // Pastikan file ini ada! - exit; - } else { - // Login Gagal - $_SESSION['error'] = "Username atau Password salah!"; - header("Location: index.php"); + // Cek Password + if (!$user || !password_verify($password, $user['password'])) { + // Redirect dengan parameter 'error=gagal' agar ditangkap JS Login + header("Location: index.php?error=gagal"); exit; } + + // Login Sukses + $_SESSION['user'] = $user; + header("Location: mainboard.php"); + exit; } ?> \ No newline at end of file diff --git a/gameboard-hard.html b/gameboard-hard.html index 896e80f..37e35e5 100644 --- a/gameboard-hard.html +++ b/gameboard-hard.html @@ -19,6 +19,46 @@ body { flex-direction: column; } +/* --- TAMBAHAN CSS COUNTDOWN & MUSIC CONTROL --- */ +#countdown-overlay { + position: fixed; + top: 0; left: 0; width: 100%; height: 100%; + background: rgba(0,0,0,0.85); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; + color: white; + font-size: 150px; + font-weight: 800; + display: none; +} + +.pulse-anim { + animation: pulse 1s ease-out infinite; +} + +@keyframes pulse { + 0% { transform: scale(1); opacity: 1; } + 100% { transform: scale(2); opacity: 0; } +} + +.music-control { + position: fixed; + bottom: 20px; + right: 20px; + z-index: 100; + background: white; + width: 45px; + height: 45px; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + box-shadow: 0 4px 10px rgba(0,0,0,0.3); + font-size: 20px; +} .topbar { display: flex; @@ -56,7 +96,6 @@ body { box-shadow: 0 3px 6px rgba(0,0,0,0.2), inset 0 0 6px rgba(255,255,255,0.6); } - .gameboard { flex: 1; display: grid; @@ -65,9 +104,9 @@ body { gap: 8px; padding: 10px; box-sizing: border-box; + place-items: center; } - .card { width: 100%; height: 100%; @@ -84,7 +123,6 @@ body { border-radius: 10px; } - .front, .back { position: absolute; width: 100%; @@ -116,7 +154,6 @@ body { filter: drop-shadow(0 3px 4px rgba(0,0,0,0.45)); } - .card:not(.flipped):hover .front { transform: scale(1.05); transition: 0.25s; @@ -124,14 +161,12 @@ body { .card.flipped .inner { transform: rotateY(180deg); } - .card.matched .front, .card.matched .back { border-color: #7affd6; box-shadow: 0 0 15px #7affd6, 0 0 30px rgba(122,255,214,0.8); } - .combo-popup { position: absolute; padding: 12px 20px; @@ -145,6 +180,7 @@ body { animation: comboFade 1.4s ease forwards; pointer-events: none; border: 2px solid rgba(255,255,255,0.35); + z-index: 100; } @keyframes comboFade { @@ -208,6 +244,17 @@ body { +
+ + + + + + + + +
🔇
+
@@ -218,29 +265,71 @@ body {
+
-
🎉 Selamat!
-

Anda berhasil menyelesaikan permainan!

+
🎉 Selamat!
+

Anda berhasil menyelesaikan permainan!

Skor Base: 0
Time Bonus: 0
Move Bonus: 0

-
Total Skor: 0
- -
- + \ No newline at end of file diff --git a/index.php b/index.php index bad5891..0866633 100644 --- a/index.php +++ b/index.php @@ -4,11 +4,9 @@ Login & Register - Memory Game - - @@ -18,7 +16,6 @@
-

Selamat Datang! ✨

Login untuk bermain