Add registration feature

This commit is contained in:
Andrew Trieu
2023-02-04 15:32:11 +02:00
parent db56a1529d
commit c717c9e4c1
9 changed files with 228 additions and 8 deletions

27
js/register.js Normal file
View File

@@ -0,0 +1,27 @@
const form = document.querySelector(".register 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/register.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);
};