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
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
$username = $_POST["username"];
|
||||
$email = $_POST["email"];
|
||||
$username = trim($_POST["username"]);
|
||||
$email = trim($_POST["email"]);
|
||||
$password = $_POST["password"];
|
||||
$confirm = $_POST["confirm"];
|
||||
|
||||
@ -21,27 +21,32 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
exit;
|
||||
}
|
||||
|
||||
// contoh simpan ke file JSON
|
||||
$file = "users.json";
|
||||
$users = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
|
||||
|
||||
// 🔍 Cek username & email duplikat
|
||||
foreach ($users as $u) {
|
||||
if ($u["username"] === $username) {
|
||||
if (strtolower($u["username"]) === strtolower($username)) {
|
||||
echo "Username sudah digunakan";
|
||||
exit;
|
||||
}
|
||||
if ($u["email"] === $email) {
|
||||
if (strtolower($u["email"]) === strtolower($email)) {
|
||||
echo "Email sudah digunakan";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// 🔐 Enkripsi password
|
||||
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
// 📌 tambah user baru
|
||||
$users[] = [
|
||||
"id" => time(),
|
||||
"id" => uniqid(),
|
||||
"username" => $username,
|
||||
"email" => $email,
|
||||
"password" => $password,
|
||||
"role" => "player"
|
||||
"password" => $hashedPassword,
|
||||
"role" => "player",
|
||||
"created_at" => date("Y-m-d H:i:s")
|
||||
];
|
||||
|
||||
file_put_contents($file, json_encode($users, JSON_PRETTY_PRINT));
|
||||
|
||||