I have been working on a sign up page and my data isn't being stored to the database. Code is below. There are no console errors. I have tried lots of different ideas and I just want data to be stored. Also, another question, is there a way to check if two values in the database are under the same email? I am wondering this for a password system. Can I please get some help. I really am frustrated and want this to work.
<button type="button" id="signUpButton" onclick="confirmData() ; stopClicksAgain()">Sign Up!</button>
<script type="module" src="backend/database.js/"><script>
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.2/firebase-app.js";
import { getDatabase, ref, set } from "https://www.gstatic.com/firebasejs/9.22.2/firebase-database.js";
const firebaseConfig = {
apiKey: "AIzaSyDJdI7Sgr7ZGo3Do6NVswgs1UvjVcQUZbs",
authDomain: "bakerstoolbox-9ca91.firebaseapp.com",
databaseURL: "https://bakerstoolbox-9ca91-default-rtdb.firebaseio.com",
projectId: "bakerstoolbox-9ca91",
storageBucket: "bakerstoolbox-9ca91.appspot.com",
messagingSenderId: "175444196196",
appId: "1:175444196196:web:f6314c643c71315b5f1871"
};
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
//get user sign up data
var email = document.getElementById("email");
var phone = document.getElementById("phone-number");
var firstName = document.getElementById("firstName");
var lastName = document.getElementById("lastName");
//button functions
const signUpButton = document.getElementById("signUpButton");
signUpButton.addEventListener("click", signUpNewUser);
//sign up a new user
function signUpNewUser(){
set(ref(database, 'users/'), {
userEmail : email,
userPhoneNum : phone,
userFirstName : firstName,
userLastName : lastName
})
.then(() => {
console.log("GOOD")
})
.catch((error) => {
console.log("ERROR")
});
}