Skip to main content

SIGN UP, SIGN IN HTML, JS, CSS USING FIREBASE


<!DOCTYPE html>

<html lang="en" dir="ltr">

<head>

    <title>

        FORM

    </title>

    <!--add scripts-->

    <script src="https://www.gstatic.com/firebasejs/8.9.0/firebase-app.js"></script>

    <script src="https://www.gstatic.com/firebasejs/8.9.0/firebase-analytics.js"></script>

    <script src="https://www.gstatic.com/firebasejs/8.9.0/firebase-auth.js"></script>

    <script src="form.js"></script>

    </head>

<body>

    <h1>WELCOME</h1>

    <div id="frmcontainer">

      <div id="head"></div>

        <input type="email" placeholder="Email" id="email">

        <input type="password" placeholder="Password" id="password">

        <button onclick="signUp()" id="signup">Sign Up</button>

         <button onclick="signIn()" id="signin">Sign In</button>

         <button onclick="signOut()" id="signout">Sign Out</button>

    </div>

    </body>

     <style>

        body{

            background:darkslategrey;

        }

        h1{

            color: #ff4d4d;

            margin: 100px auto;

            text-align: center;

            color: #fff;

        }

        #frmcontainer

        {

            background-color:#fff;

            box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);

            width: 25%;

            height: 50%;

            margin: 10px auto;

            border-radius: 10px;

        }

        #head{

            background-color:firebrick;

            width: 100%;

            height: 10px;

            border-top-right-radius: 10px;

            border-top-left-radius: 10px;

        }

        #email,#password

        {

            width: 70%;

            height: 40px;

            display: block;

            border: none;

            outline: none;

            border-bottom: 2px solid black;

            margin-left: 5px;

        }

        #signup

        {

            background-color:#fffa65;

            color: #000;

            font-weight: bold; 

            padding: 10px 25px;

            border-radius: 10px;

            text-align: center;

            text-decoration: none;

            display: inline-block;

            font-size: 13px;

            margin-top: 10px;

            margin-left: 2px;

            border: none;

        

        }

        #signin

        {

            background-color: #32ff7e;

            color: #000;

            font-weight: bold; 

            padding: 10px 25px;

            border-radius: 10px;

            text-align: center;

            text-decoration: none;

            display: inline-block;

            font-size: 13px;

            margin-top: 10px;

            margin-left: 2px;

            border: none;

        }

        #signout

        {

            background-color: #ff4d4d;

            color: #000;

            font-weight: bold; 

            padding: 10px 25px;

            border-radius: 10px;

            text-align: center;

            text-decoration: none;

            display: inline-block;

            font-size: 13px;

            border: none;

            margin-top: 10px;

            margin-left: 2px;

            margin-bottom: 5px;

        }

    </style>

</html>


JS


  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  var firebaseConfig = {
    apiKey: "AIzaSyBWj6RXuC9TBXwYAW8YxXnv7CPn7K4j1_M",
    authDomain: "form2-d0590.firebaseapp.com",
    projectId: "form2-d0590",
    storageBucket: "form2-d0590.appspot.com",
    messagingSenderId: "833788475080",
    appId: "1:833788475080:web:e070746b7b8ea33d7a57fd",
    measurementId: "G-KE9B6CG3JF"
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);
  firebase.analytics();

//add firebase auth

const auth =firebase.auth();

//create fucntions

//sign up function

function signUp(){
    
    var mail =document.getElementById("email");
    var pass =document.getElementById("password");
    
    if(mail.value.length==0){
        alert("Email is required!")
    }
    else if(pass.value.length==0){
        alert("Password is required!")
    }
    else{
    
    const promise = auth.createUserWithEmailAndPassword(mail.value,pass.value);
    
    promise.catch(e=> alert(e.messgae))
    
        alert("Sign up successful!")
    }
}

//sign in function

function signIn(){
    
    var mail =document.getElementById("email");
    var pass =document.getElementById("password");
    
    if(mail.value.length==0){
        alert("Email is required!")
    }
    else if(pass.value.length==0){
        alert("Password is required!")
    }
    else{
    
    const promise = auth.signInWithEmailAndPassword(mail.value,pass.value);
    
    promise.catch(e=> alert(e.messgae))
    
    }
}
//sign out

function signOut(){
    auth.signOut();
    alert("Signed out")
}

//state changed

auth.onAuthStateChanged(function(user){
            if(user){
    var mail = mail.value;
    alert("Active user "+mail);
                    }
else{
    alert("No active user")
}
                        })
                        
       
                        
                        SUBSCRIBE TO OUR YOUTUBE CHANNEL
                        
                        
                        
                     

Comments

Popular posts from this blog

1. activity_main.xml Inside the activity_main.xml. <? xml version ="1.0" encoding ="utf-8" ?> <androidx.constraintlayout.widget.ConstraintLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :layout_height ="match_parent" tools :context =".MainActivity" android :background ="#182b5c" > <WebView android :layout_width ="match_parent" android :layout_height ="match_parent" android :id ="@+id/webView" android :layout_alignParentLeft ="true" android :layout_alignParentStart ="true" android :layout_alignParentTop ="true" android :layout_alignParentRight ="true" android...

HOW TO SOLVE WINDOWS 10 BLACK SCREEN WITH CURSOR PROBLEM

Perhaps you have done some updates or installed new software on your windows computer and then all you can see after logging in is a black screen with a white mouse cursor. Something more like this.. This could have happened due to some malware or some system update that is conflicting with your system settings. There are various methods you can solve this; - Manually correcting the user shell - Troubleshooting from advanced start-up option. Method 1: Manually correct the user shell 1. Open task manager while on the black screen. Press the keyboard combination Ctrl+Alt+Del or right-click at the bottom part of your black screen then move three times with your upper arrow key and press enter to open task manager. 2. A task manager window will show. Go to File >> Run new task >> type in regedit >> check the checkbox (create this task with administrator privileges) >> then click OK. 3. Double click / Expand the HKEY_LOCAL_MACHINE folder. 4. Double click / Expand ...