forked from DeepakDSA/Community-Forum-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
66 lines (58 loc) · 2.65 KB
/
signup.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up</title>
<link rel="stylesheet" href="signup.css">
</head>
<body>
<div class="form-container">
<h2>Sign Up</h2>
<form id="signup-form">
<input type="email" id="signup-email" placeholder="Email" required />
<input type="password" id="signup-password" placeholder="Create Password" required />
<input type="password" id="signup-confirm-password" placeholder="Confirm Password" required />
<button type="submit">Sign Up</button>
</form>
</div>
<!-- Firebase App (the core Firebase SDK) -->
<script src="https://www.gstatic.com/firebasejs/10.13.0/firebase-app.js"></script>
<!-- Firebase Authentication -->
<script src="https://www.gstatic.com/firebasejs/10.13.0/firebase-auth.js"></script>
<!-- Firebase Configuration -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.0/firebase-app.js";
import { getAuth, createUserWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/10.13.0/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyDdXaznFfAl3-kOBiOIbVv5G1qGGE3sAyA",
authDomain: "fir-login-45f04.firebaseapp.com",
projectId: "fir-login-45f04",
storageBucket: "fir-login-45f04.appspot.com",
messagingSenderId: "430818591657",
appId: "1:430818591657:web:5349538bac65981190fab8",
measurementId: "G-41RM5BYWX0"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
document.getElementById('signup-form').addEventListener('submit', (e) => {
e.preventDefault();
const email = document.getElementById('signup-email').value;
const password = document.getElementById('signup-password').value;
const confirmPassword = document.getElementById('signup-confirm-password').value;
if (password !== confirmPassword) {
alert('Passwords do not match!');
return;
}
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
console.log('User signed up:', userCredential.user);
window.location.href = "signin.html"; // Redirect to sign-in page after successful sign-up
})
.catch((error) => {
console.error('Error signing up:', error.message);
});
});
</script>
</body>
</html>