-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapl.js
More file actions
39 lines (33 loc) · 1.38 KB
/
Copy pathapl.js
File metadata and controls
39 lines (33 loc) · 1.38 KB
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
34
35
36
37
38
39
document.getElementById('SignUp').addEventListener('click', function(event) {
event.preventDefault();
const username = document.getElementById('signup-username').value;
const email = document.getElementById('signup-email').value;
const password = document.getElementById('signup-password').value;
const confirmPassword = document.getElementById('signup-confirm-password').value;
if (username.trim() && email.trim() && password.trim() && confirmPassword.trim()) {
if (password !== confirmPassword) {
alert('Passwords do not match.');
return;
}
fetch('signup.php', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ username, email, password, confirmPassword })
})
.then(response => response.json())
.then(data => {
alert(data.message);
window.location.href = "index.html"; // Redirect to login page or wherever you'd like
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred. Please try again.');
});
} else {
alert('Please fill in all fields.');
}
});
document.getElementById('CreateA').addEventListener('click', function(event) {
event.preventDefault();
window.location.href = 'SignUpPage.html';
});