DIDS-Coursework/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/js/changePassword.js

30 lines
772 B
JavaScript
Raw Permalink Normal View History

// 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);
}
}));
}
});