| function register() { | |
| const email = document.getElementById('regEmail').value; | |
| const password = document.getElementById('regPassword').value; | |
| if (!email || !password) { | |
| alert('Please fill in all fields.'); | |
| return; | |
| } | |
| localStorage.setItem('userEmail', email); | |
| localStorage.setItem('userPassword', password); | |
| window.location.href = 'login.html'; | |
| } | |
| function login() { | |
| const email = document.getElementById('logEmail').value; | |
| const password = document.getElementById('logPassword').value; | |
| const storedEmail = localStorage.getItem('userEmail'); | |
| const storedPassword = localStorage.getItem('userPassword'); | |
| if (email === storedEmail && password === storedPassword) { | |
| localStorage.setItem('loggedIn', true); | |
| window.location.href = 'index.html'; | |
| } else { | |
| alert('Invalid credentials.'); | |
| } | |
| } | |