-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.html
103 lines (94 loc) · 3.73 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<!-- Created By CodingNepal -->
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Login Form Design | CodeLab</title>
<link rel="stylesheet" href="signup.css">
</head>
<body>
<div class="wrapper">
<div class="title header-logo">
FairShare.com
</div>
<form id="register">
<div class="field">
<input type="text" id="name" required>
<label>Name</label>
</div>
<div class="field">
<input type="email" id="email" required>
<label>Email Address</label>
</div>
<div class="field">
<input type="password" id="pass" required>
<label>Password</label>
</div>
<div class="content">
<div class="checkbox">
<input type="checkbox" id="remember-me">
<label for="remember-me">Remember me</label>
</div>
<div class="pass-link">
<a href="#">Forgot password?</a>
</div>
</div>
<div class="field">
<input type="submit" value="Signup" id="submit">
</div>
<div class="signup-link">
Not a member? <a href="index.html">login now</a>
</div>
</form>
</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.10.0/firebase-app.js";
import { getDatabase, ref, set, get, child } from "https://www.gstatic.com/firebasejs/9.10.0/firebase-database.js";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut } from "https://www.gstatic.com/firebasejs/9.10.0/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyApyPyRNnmSf2JZMdSd8tLuOHNzZDGP9VQ",
authDomain: "fairshare-test1.firebaseapp.com",
databaseURL: "https://fairshare-test1-default-rtdb.firebaseio.com",
projectId: "fairshare-test1",
storageBucket: "fairshare-test1.appspot.com",
messagingSenderId: "675255510685",
appId: "1:675255510685:web:efabecbff6161f64d99674",
measurementId: "G-8JHNB8EQNV"
};
const app = initializeApp(firebaseConfig);
const db = getDatabase(app);
document.getElementById("submit").addEventListener('click', function(e){
e.preventDefault();
set(ref(db, "user/" + document.getElementById("name").value),{
name : document.getElementById("name").value,
email : document.getElementById("email").value,
pass : document.getElementById("pass").value
});
setTimeout(function() {
// Replace the current window with a new URL
window.location.replace("index.html");
}, 2000);
});
const auth = getAuth();
document.getElementById("register").addEventListener("click", function() {
var email = document.getElementById("email").value;
var password = document.getElementById("pass").value;
//For new registration
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
console.log(user);
alert("Registration successfully!!");
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// ..
console.log(errorMessage);
});
});
</script>
</body>
</html>