Copyright © 2009 RichoSoft All rights reserved. Made By RichoSoft.  Terms of use | Privacy policy
Welcome.All Resources.Page Counters.Tips & Tricks Menu.Contact us.My Account.Site Map.
Welcome.All Resources.Page Counters.Tips & Tricks Menu.Contact us.My Account.Site Map.
Password Protecting Web Pages with ASP
The very simplest way to password protect an individual page or pages is as detailed below. However this code does mean that all users will have to know this password:

This will also require the password to be entered on every visit to the page.
Here is the what you will need to do:
<%
If Request.Form("ChkPass") <> "Y" then
%>
<!--- Draw the Form --->
 <form method="POST" action="this_page_name.asp">
    <p align="center">
     <font face="Arial" size="2">Enter the password to view this page
       <input type="password" name="fPassword" size="20">
     </font>
    <p align="center"><input type="submit" value="Submit" name="B1"></p>
     <input type="hidden" name="ChkPass" value="Y">
 </form>
<%
Response.End
End If
If Request.Form("fPassword") <> "PASSWORD" then
Response.Write "<font face='arial' size='2'><hr><b><p align='center'>The password you entered was incorrect.<BR>Please Click <a href='this_page_name.asp'>here</a> to try again.</p></b><hr>"
Response.End
End if
%>
<!--- If the Password was correct it will allow the Rest of the Page Code below here to be displayed --->
Just below the <body> tag of your page enter the code below: (Replace  “PASSWORD”  after the <> with your password.)
Enter the following as the very first line of code on your page before the <html> tag:
<%@ LANGUAGE="VBSCRIPT" %>
Change the Page Name in the code above (after the <form method="POST" action=”), to the name of your page, ensuring it has an .asp extension.
Save the page with the same name as you entered above.
  Click here for a demo of what this code does  .
  Click to see the actual code for the Demo page  .
It does not matter that the password is hard coded into the page, as the page code is run at the server, so the end-user will never see any of the code, even if they View Source’ in their browser.
More
Password Protect Pages with an Account System