Password Protect a Web Page

You can password protect your web pages by using this simple script.
[FrontPage Save Results Component]

This script should only take you a few minutes to setup. The only thing you need to do is edit the username, password, and the page the person will direct to when the correct password is entered correctly.

 

  1. First, copy the code in the above box and paste it into an HTML web page.  The page could be named whatever you'd like:  index.html for example.

     

  2. Look for a line in the script that reads...
    if (form.id.value=="userID") { 

    This is the username.  Change "userID" it to whatever username you'd like to use.

     

  3. Now look for a line in the script that reads...
    if (form.pass.value=="password") { 

    Change "password" to the one you'd like to use.

     

  4. Now look for a line that says... 
    location="page2.html"

    This is the URL of the page that the person will be directed to when they enter the correct password.  Keep in mind this assume that the page is located in the same directory of the page the password script is on.  You may have to edit the path accordingly.  If you're not sure, just put the complete URL of the page here.  Example: http://www.yourdomain.com/file.html

     

  5. The next step is optional.  This is only if you want to alter the error messages that are displayed when the username or password is not entered correctly.  If you don't change anything in these lines, the default error messages will display.

    Look for a line that says...
    alert("Invalid Password")

    You can change "Invalid Password" to whatever message you'd like.   For example, you can make it say, "The password you entered is incorrect.  Please try again."

    You can also do the same to the user Invalid ID section.   Look for the line...
    } else { alert("Invalid UserID")

    Change "Invalid UserID" to whatever message you'd like to display when the username is incorrect.

    Congratulations!  You have just password protected a web page.

 

 
Montgomery@Hollyecho.com
Women's Computer Consulting 1994 - Present

Owensville, IN 47665-8737
812-779-6088