2nd commit: Pemisahan halaman autentifikasi dengan halaman utama, modifikasi ikon, dan pemisahakan fitur berdasarkan role

This commit is contained in:
2026-06-12 22:45:38 +07:00
parent d556912ea5
commit 319a5c878f
15 changed files with 248 additions and 236 deletions
+6 -1
View File
@@ -7,6 +7,11 @@ require_once '../koneksi.php';
$data = json_decode(file_get_contents("php://input"));
if (!empty($data->username) && !empty($data->password)) {
if (strlen($data->password) < 8) {
http_response_code(400);
die(json_encode(["error" => "Password minimal harus 8 karakter!"]));
}
try {
// Cek apakah username sudah ada
$stmt = $conn->prepare("SELECT id FROM users WHERE username = :username");
@@ -17,7 +22,7 @@ if (!empty($data->username) && !empty($data->password)) {
}
// Enkripsi password menggunakan BCRYPT
$query = "INSERT INTO users (username, password) VALUES (:username, :password)";
$query = "INSERT INTO users (username, password, role) VALUES (:username, :password, 'user')";
$stmt = $conn->prepare($query);
$stmt->bindValue(':username', htmlspecialchars(strip_tags($data->username)));
$stmt->bindValue(':password', password_hash($data->password, PASSWORD_BCRYPT));