forked from goops17/RideSharingWebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCloudFireStoreForm.js
More file actions
62 lines (46 loc) · 1.66 KB
/
CloudFireStoreForm.js
File metadata and controls
62 lines (46 loc) · 1.66 KB
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
// Initialize Firebase
var config = {
apiKey: "AIzaSyApmRAMvcs-SDBL08lykImZENr2rifpqlg",
authDomain: "ride-sharing-4c8e7.firebaseapp.com",
databaseURL: "https://ride-sharing-4c8e7.firebaseio.com",
projectId: "ride-sharing-4c8e7",
storageBucket: "ride-sharing-4c8e7.appspot.com",
messagingSenderId: "217057301737"
};
firebase.initializeApp(config);
var db = firebase.firestore();
//Listen for the form submit
document.getElementById('secondForm').addEventListener('submit', submitPostingForm);
//submitting form
function submitPostingForm(e) {
e.preventDefault();
//testing the userID
var newID = getInputValue('userID');
var fName = getInputValue('fName');
var lName = getInputValue('lName');
var mName = getInputValue('mName');
var otherEmail = getInputValue('otherEmail');
var password = getInputValue('password');
var phoneNumber = getInputValue('phoneNumber');
var wscEmail = getInputValue('wscEmail');
//userID is a test
savePost(newID, fName, lName, mName, otherEmail, password, phoneNumber, wscEmail);
}
//gets form values from the html form
function getInputValue(id) {
return document.getElementById(id).value;
}
// saving user info in database
function savePost(userID, fName, lName, mName, otherEmail, password, phoneNumber, wscEmail) {
//userID and newID is test
var newID = userID;
db.collection("Users").doc(newID).set({
fName: fName,
lName: lName,
mName: mName,
otherEmail: otherEmail,
password: password,
phoneNumber: phoneNumber,
wscEmail: wscEmail
});
}