-
Notifications
You must be signed in to change notification settings - Fork 1
/
index1.html
128 lines (117 loc) · 4.86 KB
/
index1.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> <b>Student Portal</b></title>
<link rel="stylesheet" href="style7.css">
<!---we had linked our css file----->
</head>
<body>
<div class="full-page">
<div class="navbar">
<div>
<a href='website.html'>Student Portal</a>
</div>
<nav>
<ul id='MenuItems'>
<li><button class='loginbtn' onclick="document.getElementById('login-form').style.display='block'" style="width:auto;">Login</button></li>
</ul>
</nav>
</div>
<div id='login-form'class='login-page'>
<div class="form-box">
<div class="email">
<label for="email">Email</label>
<input type="text" placeholder="Enter Email" name="email" id="email" required>
</div>
<div class="password">
<label for="psw">Password</label>
<input type="password" placeholder="Enter Password" name="psw" id="psw" required>
</div>
<p>By creating an account you agree to our Terms & condition.</p>
<button type="button" id="submitData" name="submitData" class="registerbtn">Login</button>
<!--<button type="button" id="submitData" name="submitData" class="registerbtn">Register</button>
<form id='login' class='input-group-login'>
<input type='text'class='input-field'name="email" id="email" placeholder='Email Id' required >
<input type='password'class='input-field'name="psw" id="psw" placeholder='Enter Password' required>
<input type='checkbox'class='check-box'><span>Remember Password</span>
<button type='submit'class='submit-btn'>Log in</button> -->
</form>
</div>
</div>
</div>
<script>
var x=document.getElementById('login');
var y=document.getElementById('register');
var z=document.getElementById('btn');
function login()
{
x.style.left='50px';
y.style.left='450px';
z.style.left='0px';
}
</script>
</body>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.18.0/firebase-app.js";
import { getAuth,
createUserWithEmailAndPassword,
signInWithEmailAndPassword,
signOut
} from "https://www.gstatic.com/firebasejs/9.18.0/firebase-auth.js";
import { getDatabase,set,ref,update} from "https://www.gstatic.com/firebasejs/9.18.0/firebase-database.js";
//import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.18.0/firebase-analytics.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyCPZjGnc3wS1Iahhz66uMr9rcIlqs28gBk",
authDomain: "login-with-firebase-51719.firebaseapp.com",
projectId: "login-with-firebase-51719",
storageBucket: "login-with-firebase-51719.appspot.com",
messagingSenderId: "14285123416",
appId: "1:14285123416:web:b70a1fe4bd779cc60f3f2d",
measurementId: "G-FNQLEWLZY4"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
//const analytics = getAnalytics(app);
const auth = getAuth();
const database = getDatabase(app);
submitData.addEventListener('click', (e) => {
var email = document.getElementById('email').value;
var password = document.getElementById('psw').value;
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
// ...
// save log in details into real time database
var lgDate = new Date();
update(ref(database, 'users/' + user.uid), {
last_login: lgDate,
})
.then(() => {
// Data saved successfully!
alert('user logged in successfully');
})
.catch((error) => {
// The write failed...
alert(error);
});
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
alert(errorMessage);
});
signOut(auth).then(() => {
// Sign-out successful.
}).catch((error) => {
// An error happened.
});
});
</script>
</html>