-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp2.js
33 lines (28 loc) · 1.07 KB
/
app2.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
29
30
31
32
33
document.getElementById('ResetPassword').addEventListener('click', function(event) {
window.location.href = "resetPassword.html";
});
document.getElementById('CreateA').addEventListener('click', function(event) {
window.location.href = 'create_account.html';
});
document.getElementById('login-form').addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username.trim() && password.trim()) {
fetch('send_email.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password })
})
.then(response => response.json())
.then(data => {
alert(data.message);
window.location.href = "next_page.html";
})
.catch(error => {
alert('Login failed: ' + error.message);
});
} else {
alert('Please enter both username and password.');
}
});