I have an AJAX login request that calls a PHP File which processes the request data and echo if the login is successful or not. The JS script doesn't receive any values from the request Here is the code:
document.getElementById("Login-Accedi-Btn").addEventListener("click", (event) => {
var xmlHttp = new XMLHttpRequest();
loginusernameinput = document.getElementById("Login-Username-Input").value;
loginpasswordinput = document.getElementById("Login-Password-Input").value;
if (loginusernameinput == "" || loginpasswordinput == "") {
loginerror("Errore: Username o Password vuoti");
}
xmlHttp.open("GET", "logincheckajax.php?user=" + loginusernameinput + "&password=" + loginpasswordinput, true);
xmlHttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
loginstatus = xmlHttp.responseText;
if (loginstatus == "Corretto") {
window.reload;
} else {
if (loginstatus = "SbagliatoUserOPassword") {
loginerror("Errore: Username o Password non corrispondenti")
} else {
if (loginstatus = "UsernameOPasswordNonSettati") {
loginerror("Errore: Username o Password non rilevati nell'autenticazione");
} else {
loginerror("Errore non definito");
}
}
}
}
}
})