Simple asp password page

  • Thread starter James E Middleton
  • Start date
J

James E Middleton

I am currently using this simple asp script to password protect a few pages
on my site.
Scroll down for my question, please...

______START_____________________________

<% Response.Buffer=true %>

<% If Request.Form("pw") = "SECURE" Then %>

<% Else
Response.Write "To view this page, enter a valid password." & _
"<FORM ACTION=""thispage.asp"" METHOD=""POST"">" & _
"<INPUT SIZE=10 TYPE=""password"" NAME=""pw"">" & _
"<INPUT TYPE=""submit"" NAME=""Submit"" VALUE=""Go"">" & _
"</FORM>"
End If %>

______END______________________________


______HOW IT WORKS___________________

Before the first line of code:
<% Response.Buffer=true %>

On the line following the first <body> tag: (Change SECURE to your own
password.)
<% If Request.Form("pw") = "SECURE" Then %>

Find the closing </body> tag, add one line before it. Beginning on the new
line you just created:

<% Else
Response.Write "To view this page, enter a valid password." & _
"<FORM ACTION=""thispage.asp"" METHOD=""POST"">" & _
"<INPUT SIZE=10 TYPE=""password"" NAME=""pw"">" & _
"<INPUT TYPE=""submit"" NAME=""Submit"" VALUE=""Go"">" & _
"</FORM>"
End If %>

Change 'thispage.asp' to the page you want to open.

______WHAT I'D LIKE___________________

OK, it's simple and I want to keep it simple. I do not want to use a data
base, create user accounts, have a log-in system, etc. It does exactly what
I want; I'm not guarding military secrets or any thing like that. :)



However, I would like to be able to edit the 'form' that comes up for the
password prompt. When users click on a link to the protected page a blank
page comes up with the message "To view this page, enter a valid password."
Users enter the password ant the protected page is displayed.



I can edit the 'Response.Write' line to what ever text I want, but I can't
figure out how to change the font size or alignment, etc.



Is there a way to do that with the script I've posted, or does anyone know
of a script that will allow me to do this.



I've Googled and got back about 1,000,000 hits for ASP password protection.
so I thought I'd post here and see if anyone could help me before I finish
going through the other 999,950 pages I haven't looked at yet. :-(



Thanks!
 
S

Stefan B Rusynko

In your page named thispage.asp change your code to not require the response.writes (they are implied)
(you don't need the <% Response.Buffer=true %> since the default value is already TRUE

<body>
<% If Request.Form("pw") <> "" AND Request.Form("pw") = "SECURE" Then %>
- your logged in visible formatted page content goes here in the page as pure html tags
<% Else %>
- your not logged in formatted content goes here again as pure html tags
<h1>To view this page, enter a valid password.</h1>
<FORM ACTION="thispage.asp" METHOD="POST">
<INPUT SIZE=10 TYPE="password" NAME="pw">
- add form field validation to make the input required and a min/max length, etc.
<INPUT TYPE="submit" NAME="Submit" VALUE="Go">
</FORM>
<% End If %>
</body>





|I am currently using this simple asp script to password protect a few pages
| on my site.
| Scroll down for my question, please...
|
| ______START_____________________________
|
| <% Response.Buffer=true %>
|
| <% If Request.Form("pw") = "SECURE" Then %>
|
| <% Else
| Response.Write "To view this page, enter a valid password." & _
| "<FORM ACTION=""thispage.asp"" METHOD=""POST"">" & _
| "<INPUT SIZE=10 TYPE=""password"" NAME=""pw"">" & _
| "<INPUT TYPE=""submit"" NAME=""Submit"" VALUE=""Go"">" & _
| "</FORM>"
| End If %>
|
| ______END______________________________
|
|
| ______HOW IT WORKS___________________
|
| Before the first line of code:
| <% Response.Buffer=true %>
|
| On the line following the first <body> tag: (Change SECURE to your own
| password.)
| <% If Request.Form("pw") = "SECURE" Then %>
|
| Find the closing </body> tag, add one line before it. Beginning on the new
| line you just created:
|
| <% Else
| Response.Write "To view this page, enter a valid password." & _
| "<FORM ACTION=""thispage.asp"" METHOD=""POST"">" & _
| "<INPUT SIZE=10 TYPE=""password"" NAME=""pw"">" & _
| "<INPUT TYPE=""submit"" NAME=""Submit"" VALUE=""Go"">" & _
| "</FORM>"
| End If %>
|
| Change 'thispage.asp' to the page you want to open.
|
| ______WHAT I'D LIKE___________________
|
| OK, it's simple and I want to keep it simple. I do not want to use a data
| base, create user accounts, have a log-in system, etc. It does exactly what
| I want; I'm not guarding military secrets or any thing like that. :)
|
|
|
| However, I would like to be able to edit the 'form' that comes up for the
| password prompt. When users click on a link to the protected page a blank
| page comes up with the message "To view this page, enter a valid password."
| Users enter the password ant the protected page is displayed.
|
|
|
| I can edit the 'Response.Write' line to what ever text I want, but I can't
| figure out how to change the font size or alignment, etc.
|
|
|
| Is there a way to do that with the script I've posted, or does anyone know
| of a script that will allow me to do this.
|
|
|
| I've Googled and got back about 1,000,000 hits for ASP password protection.
| so I thought I'd post here and see if anyone could help me before I finish
| going through the other 999,950 pages I haven't looked at yet. :-(
|
|
|
| Thanks!
|
|
|
|
|
 
J

James E Middleton

Perfect!!!

Exactly..... exactly what I was looking for!!!!

Thanks so much.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top