eHow launches Android app: Get the best of eHow on the go.

How To

How to Design a Password Protected Web Page

Contributor
By Catherine Johnson
eHow Contributing Writer
(0 Ratings)
Create a password protected web page with javascript.
Create a password protected web page with javascript.
sxc.hu/fishmonk

Everything we upload online is usually immediately viewable and accessible by anyone with an Internet connection. However, sometimes we need to create private web content that we would like to make available to only a few family and friends. A simple javascript can create a preliminary log-in form that visitors need to pass in order to access a certain web page. Here is a step-by-step guide on how to quickly password protect a web page.

Difficulty: Easy
Instructions

Things You'll Need:

  • HTML editor FTP program
  1. Step 1

    Open your HTML editor and create a new HTML document.

  2. Step 2

    Add the following javascript after the first header tag (<head>) but before the closing of the header (</head>).

    <script language="javascript">
    <!-- function pasuser(form) { if (form.id.value=="UserName") { if (form.pass.value=="YourPassword") { location="http://yourprotectedwebpage.com/" } else { alert("Wrong Password") } } else { alert("Wrong Username") } } -->
    </script>
    <form name="login">
    Username: <input name="id" size="10" type="text">Password: <input name="pass" size="20" type="password"><input value="Submit" onclick="pasuser(this.form)" type="button">
    </form>

  3. Step 3

    In the javascript, replace "UserName" with your desired log-in name. Replace "YourPassword" with your secret password and enter the URL address of the webpage you want to protect in "yourprotectedwebpage.com."

  4. Step 4

    Save your HTML page. Open your FTP program and upload your HTML page to your server. Make sure that visitors to your site are directed to this log-in page. This ensures that they have to pass through this portal before viewing your protected webpage.

Tips & Warnings
  • This is a simple password protection script that requires a log-in page before gaining access to your protected content. For more security, it is better to create password protection directly through your web server. Contact your hosting company or web server provider for instructions on how to do this.
Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Internet Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

Demand Media
eHow_eHow Technology and Electronics