fear:mainboard

This commit is contained in:
Evelyn 2025-11-24 14:46:23 +07:00
parent 3a17b7239b
commit 3c906dfa00
7 changed files with 323 additions and 58 deletions

View File

@ -0,0 +1,43 @@
body {
font-family: Arial, sans-serif;
background: #1e90ff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
background: #fff;
padding: 25px;
border-radius: 10px;
width: 300px;
text-align: center;
}
input {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #aaa;
border-radius: 5px;
}
button {
width: 100%;
padding: 10px;
background: #1e90ff;
color: white;
border: none;
border-radius: 5px;
}
button:hover {
background: #0c65b2;
}
#error {
color: red;
margin-top: 10px;
}

View File

@ -1,34 +1,72 @@
<!-- index.html -->
<!doctype html>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Halaman Login</title>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login Page</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="container" aria-live="polite">
<h1>Masuk ke Akun Anda</h1>
<p class="lead">Masukkan email dan kata sandi.</p>
<div class="min-h-screen flex items-center justify-center p-4 relative overflow-hidden">
<form id="loginForm" novalidate>
<div class="form-group">
<label for="email">Email</label>
<input id="email" name="email" type="email" placeholder="name@contoh.com" required>
<div class="error" id="emailError"></div>
<!-- Animated Background -->
<div class="bg-animated">
<div class="bg-circle one"></div>
<div class="bg-circle two"></div>
<div class="bg-circle three"></div>
</div>
<div class="form-group password-row">
<label for="password">Kata sandi</label>
<input id="password" name="password" type="password" placeholder="Masukkan kata sandi" required minlength="6">
<button type="button" class="toggle-pass" id="togglePass">Tampilkan</button>
<div class="error" id="passError"></div>
<!-- Login Card -->
<div class="login-card">
<div class="icon-wrapper">
<div class="icon-bg"></div>
<div class="icon-circle">
<img src="login-icon.png" class="login-icon" />
</div>
<button id="submitBtn" type="submit">Masuk</button>
<div id="result"></div>
</div>
<div class="header-text">
<h2>Selamat Datang! ✨</h2>
<p>Login untuk bermain Memory Card Game</p>
</div>
<form id="loginForm">
<label>Username</label>
<input type="text" id="username" placeholder="Masukkan username">
<label>Password</label>
<input type="password" id="password" placeholder="Masukkan password">
<div id="errorBox" class="error"></div>
<button type="submit" class="btn-login">Login Sekarang</button>
</form>
</main>
<p class="register-text">
Belum punya akun?
<a href="register.html">Daftar Sekarang</a>
</p>
<div class="demo-box">
<p><strong>🎮 Demo Akun</strong></p>
<div class="demo-item">
<p><strong>Player:</strong></p>
<p>Username: <code>player</code></p>
<p>Password: <code>player123</code></p>
</div>
<div class="demo-item">
<p><strong>Admin:</strong></p>
<p>Username: <code>admin</code></p>
<p>Password: <code>admin123</code></p>
</div>
</div>
</div>
</div>
<script src="login.js"></script>
</body>
</html>

View File

@ -1,39 +1,49 @@
<?php
session_start();
// untuk halaman login
include "koneksi.php";
if (isset($_POST['username']))
{
$username=$_POST['username'];
}
else $username ='';
if (isset($_POST['password']))
{
$password=$_POST['password'];
}
else $password ='';
if ($username!='' || $password!='')
{
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
// Pastikan kedua field terisi
if ($username != '' && $password != '') {
$stmt = mysqli_prepare($conn, "select * from user where username=? and password=?");
$enc = md5($password);
mysqli_stmt_bind_param($stmt, "ss", $username, $enc);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row=mysqli_fetch_assoc($result))
{
echo "Login sukses";
$_session['firstname'] = $row['firstname']; //simpan session firstname
$_session['lastname'] = $row['lastname'];
header("Location:dashboard.php"); //untuk pindah ke halaman dashboard.php
if ($row = mysqli_fetch_assoc($result)) {
// Simpan session dengan nama yang benar
$_SESSION['firstname'] = $row['firstname'];
$_SESSION['lastname'] = $row['lastname'];
echo "firstname:".$row['firstname']."<br>";//kalo di file yang sama
echo "lastname:".$row['lastname']."<br>";
// Jika request AJAX, kembalikan JSON, jika bukan, redirect ke dashboard
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
if ($isAjax) {
header('Content-Type: application/json');
echo json_encode(['success' => true, 'message' => 'Login sukses']);
exit;
} else {
header("Location: dashboard.php");
exit;
}
} else {
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
if ($isAjax) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'message' => 'Username/password salah']);
exit;
} else {
echo "Username/password salah";
}
}
else echo "Username/password salah";
}
?>
<!doctype html>
<html>
<body>
<form method="POST">

44
mainboard.css Normal file
View File

@ -0,0 +1,44 @@
body {
margin: 0;
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #7b2ff7, #f107a3);
color: white;
}
.container { padding: 20px; max-width: 1000px; margin: auto; }
.header {
display: flex; justify-content: space-between; align-items: center;
padding: 15px 20px; border-radius: 20px; margin-bottom: 20px;
}
.user-info { display: flex; align-items: center; gap: 15px; }
.user-icon {
width: 50px; height: 50px; border-radius: 50%;
background: #fff; color: #000; display:flex; align-items:center; justify-content:center;
font-size: 20px; font-weight: bold;
}
.actions button { margin-left: 10px; }
.btn {
padding: 10px 20px; border: none; border-radius: 10px;
font-size: 15px; cursor: pointer;
}
.gold { background: gold; }
.gray { background: #444; color: white; }
.title { text-align: center; margin-top: 40px; margin-bottom: 40px; }
.stage-grid {
display: grid; grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.stage-btn {
background: white; color: black; padding: 30px; border-radius: 20px;
cursor: pointer; transition: .3s; text-align: center;
}
.stage-btn:hover { transform: scale(1.05); }
.icon { font-size: 40px; margin-bottom: 10px; display:block; }

60
mainboard.html Normal file
View File

@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Game</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<!-- HEADER -->
<header class="header glass">
<div class="user-info">
<div class="user-icon">A</div>
<div>
<h2 id="username">Player</h2>
<p id="role">🎮 Player</p>
</div>
</div>
<div class="actions">
<button id="leaderboardBtn" class="btn gold">🏆 Leaderboard</button>
<button id="logoutBtn" class="btn gray">🚪 Logout</button>
</div>
</header>
<!-- TITLE -->
<div class="title">
<h1>🎮 Memory Card Game</h1>
<p>Pilih tingkat kesulitan untuk memulai permainan</p>
</div>
<!-- STAGE SELECTION -->
<div class="stage-grid">
<button class="stage-btn easy" onclick="selectStage('easy')">
<span class="icon">😊</span>
<h3>Easy Mode</h3>
<p>Grid 3x4 (12 kartu)</p>
</button>
<button class="stage-btn medium" onclick="selectStage('medium')">
<span class="icon">🤔</span>
<h3>Medium Mode</h3>
<p>Grid 5x4 (20 kartu)</p>
</button>
<button class="stage-btn hard" onclick="selectStage('hard')">
<span class="icon">😤</span>
<h3>Hard Mode</h3>
<p>Grid 6x6 (36 kartu)</p>
</button>
</div>
</div>
<script src="mainboard.js"></script>
</body>
</html>

11
mainboard.js Normal file
View File

@ -0,0 +1,11 @@
function selectStage(stage) {
alert("Stage dipilih: " + stage);
}
document.getElementById("leaderboardBtn").addEventListener("click", () => {
alert("Menuju Leaderboard");
});
document.getElementById("logoutBtn").addEventListener("click", () => {
alert("Logout berhasil!");
});

59
mainboard.php Normal file
View File

@ -0,0 +1,59 @@
<?php
session_start();
if (!isset($_SESSION['user'])) {
header("Location: login.php");
exit();
}
$user = $_SESSION['user']; // id, username, role
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MainBoard</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<header class="header">
<div class="user-info">
<div class="avatar"><?php echo strtoupper(substr($user['username'], 0, 1)); ?></div>
<div>
<h2><?php echo $user['username']; ?>
<?php if ($user['role'] === 'admin') echo "👑"; ?>
</h2>
<p><?php echo $user['role'] === 'admin' ? "Administrator" : "Player"; ?></p>
</div>
</div>
<div class="btn-group">
<button onclick="location.href='leaderboard.php'">🏆 Leaderboard</button>
<button onclick="location.href='logout.php'">🚪 Logout</button>
</div>
</header>
<h1>🎮 Memory Card Game</h1>
<p>Pilih tingkat kesulitan untuk memulai permainan</p>
<div class="stage-grid">
<button class="stage" onclick="selectStage('easy')">
<h3>Easy Mode</h3>
<p>Grid 3x4 (12 kartu)</p>
</button>
<button class>"stage" onclick="selectStage('medium')">
<h3>Medium Mode</h3>
<p>Grid 4x4 (16 kartu)</p>
</button>
<button class="stage" onclick="selectStage('hard')">
<h3>Hard Mode</h3>
<p>Grid 5x4 (20 kartu)</p>
</button>
</div>
</div>