-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpr.js
28 lines (24 loc) · 974 Bytes
/
pr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
document.getElementById('rrr').addEventListener('click', function(event) {
event.preventDefault();
const username = document.getElementById('reset-username').value;
const oldPassword = document.getElementById('old-password').value;
const newPassword = document.getElementById('new-password').value;
if (username.trim() && oldPassword.trim() && newPassword.trim()){
fetch('resetPassword.php', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ username, oldPassword, newPassword })
})
.then(response => response.json())
.then(data => {
alert(data.message);
window.location.href = "index.html";
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred. Please try again.');
});
} else {
alert('Please fill in all fields.');
}
});