DIDS-Coursework/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/js/changePassword.js
2022-12-03 12:57:42 +00:00

30 lines
772 B
JavaScript

// Change Password stuff
document.querySelector("#changePass").addEventListener("submit", e =>
{
e.preventDefault();
let formData = new FormData();
if (document.querySelector("#pass").value !== document.querySelector("#rePass").value)
{
alert("Passwords do not match");
}
else
{
formData.append("password", document.querySelector("#rePass").value);
fetch("changePassword.php", {
method: "POST",
body: formData
}).then(res => res.json().then(json =>
{
if (json.message === "ok")
{
alert("Password changed successfully");
}
else
{
alert(json.message);
}
}));
}
});