-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
89 lines (57 loc) · 2.27 KB
/
app.js
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
// -------------THIS INITIALISES YOUR DATABASE ---------------//
var firebaseConfig = {
apiKey: "AIzaSyDR_RploDZeZuA-PiYexWRLAqgTiiW99J0",
authDomain: "nasa-spacesx.firebaseapp.com",
databaseURL: "https://nasa-spacesx-default-rtdb.firebaseio.com",
projectId: "nasa-spacesx",
storageBucket: "nasa-spacesx.appspot.com",
messagingSenderId: "590280165609",
appId: "1:590280165609:web:b8ba7da79c0aa22a8dc878",
measurementId: "G-R48HWEGQT2"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var database = firebase.database();
var ref = database.ref('users');
var object = document.getElementById("sign-in-btn");
object.onclick = function() {
function receivedData(data){
var values = data.val();
var keys = Object.keys(values);
var enteredUsername = document.getElementById("enteredUsername").value;
var enteredPassword = document.getElementById("enteredPassword").value;
var signedin = false;
for (var i = 0; i < keys.length; i++){
var k = keys[i];
var username = values[k].username;
var password = values[k].password;
if (enteredUsername == username && enteredPassword == password){
alert("You Have Successfully Signed In")
window.location.href = "homepage.html";
signedin = true
break
}
}
if(signedin == false){
alert("Please Check Your UserName and Password or SIGN-UP")
}
}
function errData(data){
console.log(data)
}
ref.on('value', receivedData, errData)
}
var object = document.getElementById("sign-btn");
console.log(object.textContent);
object.onclick = function () {
var data = {
name: document.getElementById("Your-Name").value,
username: document.getElementById("UserName").value,
password: document.getElementById("Password").value,
phone_number: document.getElementById("Phone-Number").value,
email_id: document.getElementById("Email-Id").value,
};
ref.push(data);
alert("You have successfully signed up");
window.location.reload()
};