fear:mainboard
This commit is contained in:
parent
3a17b7239b
commit
3c906dfa00
43
login.css
43
login.css
@ -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;
|
||||||
|
}
|
||||||
94
login.html
94
login.html
@ -1,34 +1,72 @@
|
|||||||
<!-- index.html -->
|
<!DOCTYPE html>
|
||||||
<!doctype html>
|
<html lang="id">
|
||||||
<html lang="id">
|
<head>
|
||||||
<head>
|
<meta charset="UTF-8" />
|
||||||
<meta charset="utf-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<title>Login Page</title>
|
||||||
<title>Halaman Login</title>
|
<link rel="stylesheet" href="style.css" />
|
||||||
<link rel="stylesheet" href="style.css">
|
</head>
|
||||||
</head>
|
<body>
|
||||||
<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>
|
<!-- Animated Background -->
|
||||||
<div class="form-group">
|
<div class="bg-animated">
|
||||||
<label for="email">Email</label>
|
<div class="bg-circle one"></div>
|
||||||
<input id="email" name="email" type="email" placeholder="name@contoh.com" required>
|
<div class="bg-circle two"></div>
|
||||||
<div class="error" id="emailError"></div>
|
<div class="bg-circle three"></div>
|
||||||
|
</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>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
<div class="form-group password-row">
|
<div class="demo-item">
|
||||||
<label for="password">Kata sandi</label>
|
<p><strong>Admin:</strong></p>
|
||||||
<input id="password" name="password" type="password" placeholder="Masukkan kata sandi" required minlength="6">
|
<p>Username: <code>admin</code></p>
|
||||||
<button type="button" class="toggle-pass" id="togglePass">Tampilkan</button>
|
<p>Password: <code>admin123</code></p>
|
||||||
<div class="error" id="passError"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<button id="submitBtn" type="submit">Masuk</button>
|
</div>
|
||||||
<div id="result"></div>
|
|
||||||
</form>
|
</div>
|
||||||
</main>
|
</div>
|
||||||
</body>
|
|
||||||
|
<script src="login.js"></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
70
login.php
70
login.php
@ -1,39 +1,49 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
//untuk halaman login
|
// untuk halaman login
|
||||||
include "koneksi.php";
|
include "koneksi.php";
|
||||||
if (isset($_POST['username']))
|
|
||||||
{
|
$username = isset($_POST['username']) ? $_POST['username'] : '';
|
||||||
$username=$_POST['username'];
|
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||||
}
|
|
||||||
else $username ='';
|
// Pastikan kedua field terisi
|
||||||
if (isset($_POST['password']))
|
if ($username != '' && $password != '') {
|
||||||
{
|
$stmt = mysqli_prepare($conn, "select * from user where username=? and password=?");
|
||||||
$password=$_POST['password'];
|
$enc = md5($password);
|
||||||
}
|
mysqli_stmt_bind_param($stmt, "ss", $username, $enc);
|
||||||
else $password ='';
|
mysqli_stmt_execute($stmt);
|
||||||
if ($username!='' || $password!='')
|
|
||||||
{
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
$stmt = mysqli_prepare($conn,"select * from user where username=? and password=?");
|
if ($row = mysqli_fetch_assoc($result)) {
|
||||||
$enc=md5($password);
|
// Simpan session dengan nama yang benar
|
||||||
mysqli_stmt_bind_param($stmt,"ss", $username,$enc);
|
$_SESSION['firstname'] = $row['firstname'];
|
||||||
mysqli_stmt_execute($stmt);
|
$_SESSION['lastname'] = $row['lastname'];
|
||||||
|
|
||||||
$result = mysqli_stmt_get_result($stmt);
|
// Jika request AJAX, kembalikan JSON, jika bukan, redirect ke dashboard
|
||||||
if ($row=mysqli_fetch_assoc($result))
|
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
|
||||||
{
|
if ($isAjax) {
|
||||||
echo "Login sukses";
|
header('Content-Type: application/json');
|
||||||
$_session['firstname'] = $row['firstname']; //simpan session firstname
|
echo json_encode(['success' => true, 'message' => 'Login sukses']);
|
||||||
$_session['lastname'] = $row['lastname'];
|
exit;
|
||||||
header("Location:dashboard.php"); //untuk pindah ke halaman dashboard.php
|
} else {
|
||||||
|
header("Location: dashboard.php");
|
||||||
echo "firstname:".$row['firstname']."<br>";//kalo di file yang sama
|
exit;
|
||||||
echo "lastname:".$row['lastname']."<br>";
|
}
|
||||||
}
|
} else {
|
||||||
else echo "Username/password salah";
|
$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";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
|||||||
44
mainboard.css
Normal file
44
mainboard.css
Normal 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
60
mainboard.html
Normal 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
11
mainboard.js
Normal 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
59
mainboard.php
Normal 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>
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user