register login integration 2
This commit is contained in:
parent
03c8e05c8d
commit
3fb9ae5e9e
@ -295,12 +295,12 @@ input:focus {
|
||||
<p>Login untuk bermain Memory Flip Card Game</p>
|
||||
</div>
|
||||
|
||||
<form id="loginForm">
|
||||
<form id="loginForm" action="login.php" method="POST">
|
||||
<label>Username</label>
|
||||
<input type="text" id="username" placeholder="Masukkan username">
|
||||
<input type="text" name="username" required id="username" placeholder="Masukan Username">
|
||||
|
||||
<label>Password</label>
|
||||
<input type="password" id="password" placeholder="Masukkan password">
|
||||
<input type="password" name="password" required id="password" placeholder="Masukan Password">
|
||||
|
||||
<div id="errorBox" class="error"></div>
|
||||
|
||||
|
||||
@ -230,18 +230,18 @@ input:focus {
|
||||
<h2 class="title">Buat Akun Baru ✨</h2>
|
||||
<p class="subtitle">Daftar untuk bermain Memory Card Game</p>
|
||||
|
||||
<form id="registerForm">
|
||||
<form id="registerForm" action="register.php" method="POST">
|
||||
<label>Username</label>
|
||||
<input type="text" id="username" placeholder="Pilih username">
|
||||
<input type="text" name="username" required id="username" placeholder="Pilih Username">
|
||||
|
||||
<label>Email</label>
|
||||
<input type="email" id="email" placeholder="email@example.com">
|
||||
<input type="email" name="email" required id="email" placeholder="Masukan Email">
|
||||
|
||||
<label>Password</label>
|
||||
<input type="password" id="password" placeholder="Minimal 6 karakter">
|
||||
<input type="password" name="password" required id="password" placeholder="Minimal 6 karakter">
|
||||
|
||||
<label>Konfirmasi Password</label>
|
||||
<input type="password" id="confirmPassword" placeholder="Ketik ulang password">
|
||||
<input type="password" name="confirm_password" id="confirm_password" required placeholder="Ketik ulang password">
|
||||
|
||||
<div id="errorBox"></div>
|
||||
|
||||
@ -261,7 +261,7 @@ input:focus {
|
||||
let username = document.getElementById("username").value.trim();
|
||||
let email = document.getElementById("email").value.trim();
|
||||
let password = document.getElementById("password").value.trim();
|
||||
let confirmPassword = document.getElementById("confirmPassword").value.trim();
|
||||
let confirmPassword = document.getElementById("confirm_password").value.trim();
|
||||
let errorBox = document.getElementById("errorBox");
|
||||
|
||||
errorBox.style.display = "none";
|
||||
@ -282,7 +282,7 @@ input:focus {
|
||||
return;
|
||||
}
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
if (password !== confirm_password) {
|
||||
showError("Password dan konfirmasi password tidak cocok");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -6,6 +6,11 @@ $email = $_POST['email'];
|
||||
$password = $_POST['password'];
|
||||
$confirm = $_POST['confirm_password'];
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
echo "<script>alert('Format email tidak valid!'); window.history.back();</script>";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($password != $confirm) {
|
||||
echo "<script>alert('Password tidak sama'); window.history.back();</script>";
|
||||
exit;
|
||||
@ -17,7 +22,7 @@ if (mysqli_num_rows($cek) > 0) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$hash = md5($password);
|
||||
$hash = md5($password);
|
||||
|
||||
$sql = "INSERT INTO user (username, email, password) VALUES ('$username', '$email', '$hash')";
|
||||
if (mysqli_query($conn, $sql)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user