From 035613c5bcfde800124c8c8aaeb4b5c32bf4fece Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Nov 2024 10:44:18 +0530 Subject: [PATCH] remember me --- SignUp/signup.html | 5 +++++ SignUp/signup.js | 39 +++++++++++++++++++++++++++++++++++++++ login/login.html | 5 +++++ 3 files changed, 49 insertions(+) diff --git a/SignUp/signup.html b/SignUp/signup.html index 723c3b67..4060eff2 100644 --- a/SignUp/signup.html +++ b/SignUp/signup.html @@ -58,6 +58,11 @@

Create Your Account

+
+ +
diff --git a/SignUp/signup.js b/SignUp/signup.js index bd139f02..5042894b 100644 --- a/SignUp/signup.js +++ b/SignUp/signup.js @@ -57,6 +57,45 @@ document.addEventListener("DOMContentLoaded", () => { registerUser(userdata); }); + document.addEventListener("DOMContentLoaded", function () { + const rememberMeCheckbox = document.getElementById("remember-me"); + + // Load the Remember Me state from local storage + rememberMeCheckbox.checked = localStorage.getItem("rememberMe") === "true"; + + // Handle form submission + document.querySelector("form").addEventListener("submit", function (event) { + event.preventDefault(); + + // Save Remember Me state in local storage + localStorage.setItem("rememberMe", rememberMeCheckbox.checked); + + // Retrieve form data + const formData = { + username: document.getElementById("username").value, + email: document.getElementById("email").value, + password: document.getElementById("password").value, + rememberMe: rememberMeCheckbox.checked + }; + + // Send form data to the server (example AJAX call, replace URL with your endpoint) + fetch('/signup', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(formData), + }) + .then(response => response.json()) + .then(data => { + console.log('Success:', data); + }) + .catch((error) => { + console.error('Error:', error); + }); + }); + }); + const registerUser = async (user) => { try { const res = await fetch("http://localhost:5000/auth/signup", { diff --git a/login/login.html b/login/login.html index 937f4e32..1e963097 100644 --- a/login/login.html +++ b/login/login.html @@ -31,6 +31,11 @@

Welcome to Gaming Tools Store!

+
+ +