 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 11th, 2005, 03:05 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ASP logon page
Hi guys! I need some help on this logon page I found in Microsoft knowledge base. I need the logon page direct the user to a page called tech.asp resided in the same folder as the logon page. However, the current one just points to page on Microsoft website, and even the user name and password show up in the URL! I know it must have something to do with the <form action> code. Please help!
Cinderella
<html>
<head>
<title>Logon Form</title>
<%
Username="Administrator"
Password="Admin"
Validated = "OK"
if Strcomp(Request.Form("User"),Username,1)=0 AND Request.Form("password") = Password then
'Set the validation cookie and redirect the user to the original page.
Response.Cookies("ValidUser") = Validated
'Check where the users are coming from within the application.
If (Request.QueryString("from")<>"") then
Response.Redirect Request.QueryString("from")
else
'If the first page that the user accessed is the Logon page,
'direct them to the default page.
Response.Redirect "MyPage.asp"
End if
Else
' Only present the failure message if the user typed in something.
If Request.Form("User") <> "" then
Response.Write "<h3>Authorization Failed.</h3>" & "<br>" & _
"Please try again.<br>#xa0;<br>"
End if
End if
%>
</head>
<body bgcolor="#FFFFFF">
<FORM ACTION=http://support-preview.partners.extranet.microsoft.com "Logon.asp?"&Request.QueryString%><input type="hidden" name="fp" value="2"><input type="hidden" name="scid" value="<%Response.Write"> method="post">
<h3>Logon Page for MyPage.asp</h3>
<p>
Username:
<INPUT TYPE="text" NAME="User" VALUE='' size="20"></INPUT>
Password:
<INPUT TYPE="password" NAME="password" VALUE='' size="20"></INPUT>
<INPUT TYPE="submit" VALUE="Logon"></INPUT>
</FORM>
</body>
</html>
|
|

February 11th, 2005, 04:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
try this
<html>
<head>
<title>Logon Form</title>
<%
IF Request.QueryString("strAction") = "Posted" Then
Username="Administrator"
Password="Admin"
Validated = "OK"
if Strcomp(Request.Form("User"),Username,1)=0 AND Request.Form("password") = Password then
'Set the validation cookie and redirect the user to the original page.
Response.Cookies("ValidUser") = Validated
Response.Redirect "tech.asp"
Else
' Only present the failure message if the user typed in something.
If Request.Form("User") <> "" then
Response.Write "<h3>Authorization Failed.</h3>" & "<br>" & _
"Please try again.<br><br>"
End if
End if
End IF
%>
</head>
<body bgcolor="#FFFFFF">
<FORM ACTION="Logon.asp?strAction=Posted" method="post">
<h3>Logon Page for MyPage.asp</h3>
<p>
Username:
<INPUT TYPE="text" NAME="User" VALUE='' size="20"></INPUT>
Password:
<INPUT TYPE="password" NAME="password" VALUE='' size="20"></INPUT>
<INPUT TYPE="submit" VALUE="Logon"></INPUT>
</FORM>
</body>
</html>
|
|

February 12th, 2005, 08:44 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
<form method="get"> = Values are sent as QueryStrings
<form method="post"> = Values are sent as request.form("elementName")
Wind is your friend
Matt
|
|

February 14th, 2005, 12:19 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi guys,
I really appreciate all your replies. I modified my script as shahchi1 suggested. However, I got the following error:
Response object error 'ASP 0156 : 80004005'
Header Error
/technology/tech_only/Logon.asp, line 9
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
It seems that this is the line causing the problem:
the Response.Cookies("ValidUser") = Validated
However, it is written within <head> part before page content starts. Any suggestions?
Thanks!
Cinderella
|
|

February 14th, 2005, 01:50 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try this code not the one I have posted earlier
<%
IF Request.QueryString("strAction") = "Posted" Then
Username="Administrator"
Password="Admin"
Validated = "OK"
if Strcomp(Request.Form("User"),Username,1)=0 AND Request.Form("password") = Password then
'Set the validation cookie and redirect the user to the original page.
Response.Cookies("ValidUser") = Validated
Response.Redirect "tech.asp"
Else
' Only present the failure message if the user typed in something.
If Request.Form("User") <> "" then
Response.Write "<h3>Authorization Failed.</h3>" & "<br>" & _
"Please try again.<br><br>"
End if
End if
End IF
%>
<html>
<head>
<title>Logon Form</title>
</head>
<body bgcolor="#FFFFFF">
<FORM ACTION="Logon.asp?strAction=Posted" method="post">
<h3>Logon Page for MyPage.asp</h3>
<p>
Username:
<INPUT TYPE="text" NAME="User" VALUE='' size="20"></INPUT>
Password:
<INPUT TYPE="password" NAME="password" VALUE='' size="20"></INPUT>
<INPUT TYPE="submit" VALUE="Logon"></INPUT>
</FORM>
</body>
</html>
|
|

February 14th, 2005, 02:37 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Shahchi1,
It worked! Many Thanks! You were a big help!
Cinderella
|
|
 |