Classplay
Chatroom
Movies
Search
Sounds
Apps
Games
Register an Account
Register
Already have an account?
Login
Login to an Account
Login
Need an account?
Register
Welcome!
Logout
main main // Initialize Appwrite client const client = new Client(); client .setEndpoint('classplay-login1') // Replace with your Appwrite endpoint .setProject('classplay-login1'); // Replace with your project ID const account = new Account(client); // Display Login Form function displayLogin() { document.getElementById('register').style.display = 'none'; document.getElementById('login').style.display = 'block'; } // Display Register Form function displayRegister() { document.getElementById('login').style.display = 'none'; document.getElementById('register').style.display = 'block'; } // Register User async function registerUser() { const email = document.getElementById('register-email').value; const password = document.getElementById('register-password').value; try { await account.create('unique()', email, password); alert('Registration successful! You can now log in.'); displayLogin(); } catch (error) { alert('Error: ' + error.message); } } // Login User async function loginUser() { const email = document.getElementById('login-email').value; const password = document.getElementById('login-password').value; try { await account.createEmailSession(email, password); alert('Login successful!'); document.getElementById('login').style.display = 'none'; document.getElementById('logout').style.display = 'block'; } catch (error) { alert('Error: ' + error.message); } } // Logout User async function logoutUser() { try { await account.deleteSession('current'); alert('Logged out successfully.'); document.getElementById('logout').style.display = 'none'; displayLogin(); } catch (error) { alert('Error: ' + error.message); } }