Finalize
This commit is contained in:
27
js/login.js
Normal file
27
js/login.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const form = document.querySelector(".login form"),
|
||||
continueBtn = form.querySelector(".button input"),
|
||||
errorText = form.querySelector(".error");
|
||||
|
||||
form.onsubmit = (e) => {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
continueBtn.onclick = () => {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "php/login.php", true);
|
||||
xhr.onload = () => {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
let data = xhr.response;
|
||||
if (data === "success") {
|
||||
location.href = "home.php";
|
||||
} else {
|
||||
errorText.style.display = "block";
|
||||
errorText.textContent = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let formData = new FormData(form);
|
||||
xhr.send(formData);
|
||||
};
|
||||
Reference in New Issue
Block a user