Compare commits
No commits in common. "ea60abb7f175065c1efce8fd399cdcb2e28d23be" and "0bec0e3f83ce1d751f12f1e3922f9b62d64fe962" have entirely different histories.
ea60abb7f1
...
0bec0e3f83
@ -5,12 +5,6 @@ include "koneksi.php";
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background: linear-gradient(to bottom right, #A3D438, #004D40);
|
|
||||||
height: 568px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<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.0">
|
||||||
|
|||||||
@ -26,10 +26,7 @@
|
|||||||
<h1 style="color: red" id="gameover-title">YOU DIED</h1>
|
<h1 style="color: red" id="gameover-title">YOU DIED</h1>
|
||||||
<p id="gameover-score">Score: 0</p>
|
<p id="gameover-score">Score: 0</p>
|
||||||
<button id="ulangi" class="modegame">Main lagi?</button>
|
<button id="ulangi" class="modegame">Main lagi?</button>
|
||||||
<a href="http://localhost/uas_sem_1/index.php">
|
<button id="keluar" class="modegame">Keluar?</button>
|
||||||
<button id="keluar" class="">Keluar?</button>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="gameover" class="gameover"></div>
|
<div id="gameover" class="gameover"></div>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
47
home.html
Normal file
47
home.html
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<html>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-image: url();
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 10%;
|
||||||
|
font-size: 85px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding: 5px;
|
||||||
|
border: 2px solid; /* Nanti dihapus */
|
||||||
|
border-radius: 7pt; /* Nanti dihapus */
|
||||||
|
width: 70%;
|
||||||
|
justify-self: center;
|
||||||
|
background-image: url();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#button {
|
||||||
|
font-size: 35px;
|
||||||
|
margin-top: 5%;
|
||||||
|
width: 50%;
|
||||||
|
margin-bottom: 5%;
|
||||||
|
border: 1px solid;
|
||||||
|
border-radius: 3pt;
|
||||||
|
padding: 2px;
|
||||||
|
justify-self: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>EAT THAT APPLE</h1>
|
||||||
|
<div class="container">
|
||||||
|
<div id="button">Play Game</div>
|
||||||
|
<div id="button">Leaderboard</div>
|
||||||
|
<div id="button">Quit</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
78
index.php
78
index.php
@ -1,82 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// buat inisialisasi session
|
||||||
session_start();
|
session_start();
|
||||||
|
// mengecek apakah ada session user yang aktif, jika tidak arahkan ke login.php
|
||||||
if(!isset($_SESSION['users'])) {
|
if(!isset($_SESSION['users'])) {
|
||||||
header('location:login.php');
|
header('location:login.php'); // arahkan ke login.php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="id">
|
<html lang="id">
|
||||||
<style>
|
<head>
|
||||||
body {
|
|
||||||
background: linear-gradient(to bottom right, #A3D438, #004D40);
|
|
||||||
height: 526px;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 10%;
|
|
||||||
font-size: 40px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
padding: 5px;
|
|
||||||
border: 2px solid; /* Nanti dihapus */
|
|
||||||
border-radius: 7pt; /* Nanti dihapus */
|
|
||||||
width: 65%;
|
|
||||||
height: 55%;
|
|
||||||
justify-self: center;
|
|
||||||
/* background-image: url(); */
|
|
||||||
}
|
|
||||||
|
|
||||||
#button {
|
|
||||||
font-size: 35px;
|
|
||||||
margin-top: 5%;
|
|
||||||
width: 50%;
|
|
||||||
margin-bottom: 5%;
|
|
||||||
border: 1px solid;
|
|
||||||
border-radius: 3pt;
|
|
||||||
padding: 2px;
|
|
||||||
justify-self: center;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
<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.0">
|
||||||
<title>Halaman ke-1</title>
|
<title>Halaman ke-1</title>
|
||||||
</head>
|
</head>
|
||||||
<body style='text-align:center'>
|
<body style='text-align:center'>
|
||||||
<h1>EAT THAT APPLE</h1>
|
<h1>Halaman ke-1</h1>
|
||||||
<!-- <a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
<a href="logout.php">Logout</a> -->
|
<a href="logout.php">Logout</a>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
|
<h3>Selamat datang, <?php echo $_SESSION['users']['nama'] ?></h3>
|
||||||
<br>
|
Halaman ini akan tampil setelah user login.
|
||||||
|
</body>
|
||||||
<!-- <h1>EAT THAT APPLE</h1> -->
|
|
||||||
<div class="container">
|
|
||||||
<div class="b2">
|
|
||||||
<a href="game.html">
|
|
||||||
<div id="button">Play Game</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="b2">
|
|
||||||
<a href="http://localhost/uas_sem_1/leaderboard.php">
|
|
||||||
<div id="button">Leaderboard</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="b2">
|
|
||||||
<a href="http://localhost/uas_sem_1/logout.php">
|
|
||||||
<div id="button">Logout</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once "koneksi.php";
|
|
||||||
|
|
||||||
if (isset($_SESSION['username'])) {
|
|
||||||
$nama = $_SESSION['username'];
|
|
||||||
} else {
|
|
||||||
$nama = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$score = 0;
|
|
||||||
|
|
||||||
if (!empty($nama)) {
|
|
||||||
$getScore = "SELECT score FROM users WHERE username = '$nama'";
|
|
||||||
$resultMe = mysqli_query($koneksi, $getScore);
|
|
||||||
|
|
||||||
if ($resultMe && mysqli_num_rows($resultMe) > 0) {
|
|
||||||
$row = mysqli_fetch_assoc($resultMe);
|
|
||||||
$score = $row['score'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "SELECT username, score FROM users ORDER BY score DESC LIMIT 10";
|
|
||||||
$result = mysqli_query($koneksi, $sql);
|
|
||||||
$leaderboard = [];
|
|
||||||
|
|
||||||
if($result) {
|
|
||||||
$leaderboard = mysqli_fetch_all($result, MYSQLI_ASSOC);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="id">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background: linear-gradient(to bottom right, #A3D438, #004D40);
|
|
||||||
height: 568px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Leaderboard</title>
|
|
||||||
<link rel="stylesheet" href="">
|
|
||||||
<link rel="stylesheet" href="">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>#</th>
|
|
||||||
<th>Username</th>
|
|
||||||
<th>Score</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
$peringkat = 1;
|
|
||||||
if (!empty($leaderboard)) {
|
|
||||||
foreach ($leaderboard as $pemain):
|
|
||||||
?>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $peringkat; ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($pemain['username']); ?></td>
|
|
||||||
|
|
||||||
<td><?php echo $pemain['score']; ?> PTS</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$peringkat++;
|
|
||||||
endforeach;
|
|
||||||
} else {
|
|
||||||
echo '<tr><td colspan="3" style="text-align: center;">Belum ada Pemain</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
54
login.php
54
login.php
@ -1,8 +1,18 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
include "koneksi.php";
|
include "koneksi.php";
|
||||||
if(isset($_POST['username'])) {
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Halaman: Login</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
if(isset($_POST['username'])) {
|
||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
$password = md5($_POST['password']);
|
$password = md5($_POST['password']);
|
||||||
|
|
||||||
@ -11,37 +21,13 @@ if(isset($_POST['username'])) {
|
|||||||
if(mysqli_num_rows($query) > 0) {
|
if(mysqli_num_rows($query) > 0) {
|
||||||
$data = mysqli_fetch_array($query);
|
$data = mysqli_fetch_array($query);
|
||||||
$_SESSION['users'] = $data;
|
$_SESSION['users'] = $data;
|
||||||
$_SESSION['username'] = $data = ['username'];
|
echo '<script>alert("Selamat datang, '.$data['nama'].'"); location.href="index.php";</script>';
|
||||||
echo '<script>location.href="index.php";</script>';
|
|
||||||
} else {
|
} else {
|
||||||
echo '<script>alert("Username atau Password tidak sesuai");</script>';
|
echo '<script>alert("Username atau Password tidak sesuai");</script>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="id">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background: linear-gradient(to bottom right, #A3D438, #004D40);
|
|
||||||
/* height: 568px; */
|
|
||||||
}
|
|
||||||
.login {
|
|
||||||
/* background-image: url('login/login.png'); */
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-size: 300px 190px;
|
|
||||||
background-position: center top;
|
|
||||||
height: 568px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Halaman: Login</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="login">
|
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<table align="center">
|
<table align="center">
|
||||||
<tr>
|
<tr>
|
||||||
@ -51,12 +37,12 @@ if(isset($_POST['username'])) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td></td>
|
<td>Username</td>
|
||||||
<td><input type="text" name="username" placeholder="Username" style="border: none"></td>
|
<td><input type="text" name="username"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td>Password</td>
|
||||||
<td><input type="password" name="password" placeholder="Password" style="border: none"></td>
|
<td><input type="password" name="password"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -67,8 +53,6 @@ if(isset($_POST['username'])) {
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</body>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
BIN
login/log.png
BIN
login/log.png
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
BIN
login/login.png
BIN
login/login.png
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.8 KiB |
69
users.sql
69
users.sql
@ -1,69 +0,0 @@
|
|||||||
-- phpMyAdmin SQL Dump
|
|
||||||
-- version 5.2.0
|
|
||||||
-- https://www.phpmyadmin.net/
|
|
||||||
--
|
|
||||||
-- Host: localhost:3306
|
|
||||||
-- Generation Time: Dec 03, 2025 at 05:17 AM
|
|
||||||
-- Server version: 8.0.30
|
|
||||||
-- PHP Version: 8.1.10
|
|
||||||
|
|
||||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
|
||||||
START TRANSACTION;
|
|
||||||
SET time_zone = "+00:00";
|
|
||||||
|
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
||||||
/*!40101 SET NAMES utf8mb4 */;
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Database: `game`
|
|
||||||
--
|
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table structure for table `users`
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TABLE `users` (
|
|
||||||
`id_user` int NOT NULL,
|
|
||||||
`nama` varchar(255) DEFAULT NULL,
|
|
||||||
`username` varchar(225) DEFAULT NULL,
|
|
||||||
`password` varchar(255) DEFAULT NULL,
|
|
||||||
`score` int NOT NULL
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Dumping data for table `users`
|
|
||||||
--
|
|
||||||
|
|
||||||
INSERT INTO `users` (`id_user`, `nama`, `username`, `password`, `score`) VALUES
|
|
||||||
(1, 'Chris Daud Koroh', 'daudkoroh', '88d602f1ad6d62b9a11c688ab47fed22', 20),
|
|
||||||
(2, 'Zefanya Isaac', 'zefanya', 'de413c0365e3c88d8b3315f9d90b98ae', 68);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Indexes for dumped tables
|
|
||||||
--
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Indexes for table `users`
|
|
||||||
--
|
|
||||||
ALTER TABLE `users`
|
|
||||||
ADD PRIMARY KEY (`id_user`);
|
|
||||||
|
|
||||||
--
|
|
||||||
-- AUTO_INCREMENT for dumped tables
|
|
||||||
--
|
|
||||||
|
|
||||||
--
|
|
||||||
-- AUTO_INCREMENT for table `users`
|
|
||||||
--
|
|
||||||
ALTER TABLE `users`
|
|
||||||
MODIFY `id_user` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user