Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
Create a website using HTML CSS and JavaScript that stores data in Firebase
Next article icon

Create a website using HTML CSS and JavaScript that stores data in Firebase

Last Updated : 18 Dec, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Following are some simple steps in order to connect our static Web Page with Firebase. 

Step-by-Step Implementation

Step 1: Firstly, We are going to create a project on Firebase to connect our static web page. Visit the Firebase page to configure your project. Visit the website and click the On Add Project button as shown below.

Step 2: Give a Name to your project and click on the Continue button.

Step 3: Now click on the Continue button.

Step 4: Now choose Default Account For Firebase and click on the Create Project button.

Step 5: Now your project is created and you are now good to go.

Step 6: Now click on the 3rd icon that's the Web button(</>).

Step 7: Give a nickname to your web project and click on the Register App button.

Step 8: Now you will see the configuration of your App like this. Copy this code somewhere as we will use it later.

Step 9: Click on the Realtime Database as shown below.

Step 10: Now click on the Create Database button.

Step 11: Now click on the Test Mode and then click on the Enable button.

Step 12: Activate Firebase Storage. Click on Storage button in the left and the click on Get Started.

After that this box will pop up . Click on Next.
 

Then Click on Done.
 

Project Setup:

Now Create an HTML file and copy the script code which you copied in Step 8. The following file is just a sample for you to understand how to configure your project.

Example: This example shows the use of Firebase with HTML and CSS.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <title>Collecting Data</title>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">     </script>      <link rel="stylesheet" href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"         integrity= "sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"         crossorigin="anonymous"> </head>  <body class="container" style="margin-top: 50px;     width: 50%; height:auto;">          <h2 class="text-primary" style=         "margin-left: 15px; margin-bottom: 10px">         Hey There,Help Us In Collecting Data     </h2>          <form class="container" id="contactForm">         <div class="card">             <div class="card-body">                 <div class="form-group">                     <label for="exampleFormControlInput1">                         Enter Your Name                     </label>                                          <input type="text" class="form-control"                      id="name" placeholder="Enter your name">                 </div>                  <div class="form-group">                     <label for="exampleFormControlInput1">                         Email address                     </label>                                          <input type="email" class="form-control"                      id="email" placeholder="[email protected]">                 </div>             </div>             <button type="submit" class="btn btn-primary"                 style="margin-left: 15px; margin-top: 10px">                 Submit             </button>         </div>     </form>      <script src= "https://www.gstatic.com/firebasejs/3.7.4/firebase.js">     </script>          <script>         let firebaseConfig = {             apiKey: "Use Your Api Key Here",             authDomain: "Use Your authDomain Here",             databaseURL: "Use Your databaseURL Here",             projectId: "Use Your projectId Here",             storageBucket: "Use Your storageBucket Here",             messagingSenderId: "Use Your messagingSenderId Here",             appId: "Use Your appId Here"         };          firebase.initializeApp(firebaseConfig);          let messagesRef = firebase.database()             .ref('Collected Data');                  document.getElementById('contactForm')             .addEventListener('submit', submitForm);          function submitForm(e) {             e.preventDefault();              // Get values             let name = getInputVal('name');             let email = getInputVal('email');              saveMessage(name, email);             document.getElementById('contactForm').reset();         }          // Function to get form values         function getInputVal(id) {             return document.getElementById(id).value;         }          // Save message to firebase         function saveMessage(name, email) {             let newMessageRef = messagesRef.push();             newMessageRef.set({                 name: name,                 email: email,             });         }     </script> </body>  </html> 

Output:

Entering some sample values of Name and Email address in the given form as shown below.

After clicking the Submit button, the data is getting stored in the real-time database as shown below.


Next Article
Create a website using HTML CSS and JavaScript that stores data in Firebase

A

annianni
Improve
Article Tags :
  • Technical Scripter
  • JavaScript
  • Web Technologies
  • How To
  • Firebase
  • JavaScript-Projects

Similar Reads

    How to Create a Portfolio Website using HTML CSS and JavaScript ?
    A portfolio website is a website that represents you online on the web pages. It contains different sections like Introduction to Yourself, About You, Your Services, Your Contact Details, and Your Portfolio. We are going to build all of the sections with an interactive and attractive web design that
    15+ min read
    Create a Music Website Template using HTML, CSS & JavaScript
    A Music Website Template is a pre-designed layout for creating a music-themed webpage. By utilizing HTML, CSS, and JavaScript, developers can craft a functional and visually appealing website with features like play/pause controls, sections for home, music, about, and contact.Step-by-Step Guide to c
    3 min read
    Create a Data Export and Import using HTML CSS and JavaScript
    In this article, we are going to implement a Data Export and Import Project using HTML CSS & JavaScript. The application we are going to create will allow the user to export their data to a CSV file effortlessly and then import data back from CSV files. Whether you're managing lists or working w
    3 min read
    Design a School Website in HTML CSS and JavaScript
    A School Website developed using HTML, CSS, and JavaScript is an interactive platform that provides information about the school, its faculty, courses, events, and other relevant details. It incorporates responsive design principles to ensure compatibility across various devices, offering an engagin
    8 min read
    Design a Online Cake Shop Website in HTML CSS & JavaScript
    Every business is going online nowadays for better growth and productivity. We are going to build an online cake shop website that will represent the shop in a good manner having features of online ordering and views and many more.PrerequisitesHTMLCSSJavaScriptApproachWe first create an HTML file wh
    14 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences