Step-by-Step Guide: Adding Password Protected Google Form to Your Blogger Post

Have you ever wanted to create a password-protected Blogger post and integrate a Google Form into it? In this comprehensive guide, we'll walk you through the step-by-step process of adding password protection to your Blogger post and embedding a Google Form. We'll also provide you with the necessary HTML code.

Step-by-Step Guide: Adding Password Protected Google Form to Your Blogger Post


Step 1: Create a New Blogger Post

Start by logging into your Blogger account and creating a new post. Give it a title and add your desired content. Remember that this guide assumes you have basic knowledge of HTML.


Step 2: Password Protection HTML Code

Copy the following HTML code snippet and paste it at the beginning of your Blogger post, right after the opening <body> tag:

<!DOCTYPE html>

<html>

<head>

  <title>Password-Protected Blogger Post</title>

  <script>

    function setCookie(cname, cvalue, exdays) {

      var d = new Date();

      d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));

      var expires = "expires=" + d.toUTCString();

      document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";

    }


    function getCookie(cname) {

      var name = cname + "=";

      var decodedCookie = decodeURIComponent(document.cookie);

      var ca = decodedCookie.split(';');

      for (var i = 0; i < ca.length; i++) {

        var c = ca[i];

        while (c.charAt(0) == ' ') {

          c = c.substring(1);

        }

        if (c.indexOf(name) == 0) {

          return c.substring(name.length, c.length);

        }

      }

      return "";

    }


    function showGoogleForm() {

      document.getElementById("googleFormContainer").innerHTML = 'Add Your Embed Google Form Here';

      document.getElementById("passwordSection").style.display = "none";

    }


    function checkPassword() {

      var password = document.getElementById("passwordInput").value;

      if (password === "xxxx") {

        setCookie("accessGranted", true, 30); // Save a cookie for 30 days

        showGoogleForm();

      } else {

        alert("Incorrect password. Please try again.");

      }

    }


    window.onload = function() {

      var accessGranted = getCookie("accessGranted");

      if (accessGranted === "true") {

        showGoogleForm();

      }

    };

  </script>

</head>


In the above code just replace the text "Add Your Embed Google Form Here" with your google form html code.

Step 3: HTML Markup

Now, add the following HTML code wherever you want to display the password section and the Google Form:

<body>

  <h2>Password-Protected Blogger Post</h2>


  <div id="googleFormContainer"></div>


  <div id="passwordSection">

    <label for="passwordInput">Enter Password:</label>

    <input type="password" id="passwordInput" />

    <button onclick="checkPassword()">Submit</button>

  </div>

</body>

</html>


Step 4: Publish and Test

Finally, preview your post and publish it. You should now see a password section asking for the password. Enter the correct password (in this case, "xxxx"), and the Google Form will be displayed.


Remember, this is just a basic implementation. You can further customize the styling and add additional features as per your requirements.


By following these simple steps and incorporating the provided HTML code, you can easily create a password-protected Blogger post with an embedded Google Form. Enjoy engaging with your readers and gathering valuable insights!


Keywords: make quiz in blogger, add Google Form in Blogger, HTML code for password-protected blog post 

If you have any doubt, Please let me know

Post a Comment (0)
Previous Post Next Post