mengganti asset gambar buah
|
Before Width: | Height: | Size: 28 KiB |
BIN
asset/anggur.jpg
|
Before Width: | Height: | Size: 26 KiB |
BIN
asset/apel.jpg
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 56 KiB |
BIN
asset/jambu.jpg
|
Before Width: | Height: | Size: 8.7 KiB |
BIN
asset/jeruk.jpg
|
Before Width: | Height: | Size: 31 KiB |
BIN
asset/lemon.jpg
|
Before Width: | Height: | Size: 48 KiB |
BIN
asset/nanas.jpg
|
Before Width: | Height: | Size: 20 KiB |
BIN
asset/pisang.jpg
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 29 KiB |
21
register.php
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
|
||||||
$username = $_POST["username"];
|
$username = trim($_POST["username"]);
|
||||||
$email = $_POST["email"];
|
$email = trim($_POST["email"]);
|
||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
$confirm = $_POST["confirm"];
|
$confirm = $_POST["confirm"];
|
||||||
|
|
||||||
@ -21,27 +21,32 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// contoh simpan ke file JSON
|
|
||||||
$file = "users.json";
|
$file = "users.json";
|
||||||
$users = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
|
$users = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
|
||||||
|
|
||||||
|
// 🔍 Cek username & email duplikat
|
||||||
foreach ($users as $u) {
|
foreach ($users as $u) {
|
||||||
if ($u["username"] === $username) {
|
if (strtolower($u["username"]) === strtolower($username)) {
|
||||||
echo "Username sudah digunakan";
|
echo "Username sudah digunakan";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if ($u["email"] === $email) {
|
if (strtolower($u["email"]) === strtolower($email)) {
|
||||||
echo "Email sudah digunakan";
|
echo "Email sudah digunakan";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔐 Enkripsi password
|
||||||
|
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);
|
||||||
|
|
||||||
|
// 📌 tambah user baru
|
||||||
$users[] = [
|
$users[] = [
|
||||||
"id" => time(),
|
"id" => uniqid(),
|
||||||
"username" => $username,
|
"username" => $username,
|
||||||
"email" => $email,
|
"email" => $email,
|
||||||
"password" => $password,
|
"password" => $hashedPassword,
|
||||||
"role" => "player"
|
"role" => "player",
|
||||||
|
"created_at" => date("Y-m-d H:i:s")
|
||||||
];
|
];
|
||||||
|
|
||||||
file_put_contents($file, json_encode($users, JSON_PRETTY_PRINT));
|
file_put_contents($file, json_encode($users, JSON_PRETTY_PRINT));
|
||||||
|
|||||||