Solved

fix problem in simple asp login page; add username field

Posted on 2007-11-19
5
415 Views
Last Modified: 2012-06-22
I've got a simple asp login page, but it's got two little problems I need to fix.
1) When login fails, we lose the original target url. We need to keep that information.
2) I need to add a username field.

Who can help?

Thanks!

gesswurker
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
dim targetUrl
      If Request.Cookies("PasswordIsValidated") = "true" Then
            Response.Redirect(Replace(Request.QueryString("target"),"gggAmPggg","&"))
      End If
      
      If Request.QueryString("action")="login" Then
            dim pwd
            pwd = "password"
            dim username
            username = "username"
       
            If pwd = Trim(Request.Form("txtPassword")) Then
                  Response.Cookies("PasswordIsValidated") = "true"
                  Response.Redirect(Replace(Request.QueryString("target"),"gggAmPggg","&"))
            Else
                  Response.Redirect("password.asp?result=loginfailed") 'here's where I need to include the target url
            End If
      End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<link href="bibliography.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
}
-->
</style></head>
<br/>
<body>
<table border="0"><tr><td width="50">&nbsp;</td><td>
    <form action="password.asp?action=login&target=<%=Request.QueryString("target")%>" method="post">
            <% If Request.QueryString("result")="loginfailed" Then %>
                <p>Login failed. Please check that you have entered the correct password.</p>
            <% End If %>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="22%"><h1>Login</h1></td>
                <td width="78%">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" colspan="2">A password is required in order to request items from the AIM-VA Catalog. </td>
              </tr>
              <tr>
                <td height="44">Password: </td>
                <td><input type="password" id="txtPassword" name="txtPassword" /></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><input type="submit" id="btnLogin" name="btnLogin" value="Login" onclick="return ValidateLogin();" /></td>
                <td>&nbsp;</td>
              </tr>
            </table>
            <h2>&nbsp;</h2>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
    </form>
</td></tr></table>
</body>
</html>

Open in new window

0
Comment
Question by:GessWurker
  • 3
  • 2
5 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 20313772
Response.Redirect("password.asp?result=loginfailed&target=" & Request.QueryString("target")) 'here's where I need to include the target url
0
 

Author Comment

by:GessWurker
ID: 20313841
I also need a username field along with a validation test.
0
 
LVL 82

Expert Comment

by:hielo
ID: 20313881
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
dim targetUrl
      If Request.Cookies("PasswordIsValidated") = "true" Then
            Response.Redirect(Replace(Request.QueryString("target"),"gggAmPggg","&"))
      End If
     
      If Request.QueryString("action")="login" Then
            dim pwd
            pwd = "password"
            dim username
            username = "username"
       
            If pwd = Trim(Request.Form("txtPassword")) AND username = Trim(Request.Form("txtUsename")) Then
                  Response.Cookies("PasswordIsValidated") = "true"
                  Response.Redirect(Replace(Request.QueryString("target"),"gggAmPggg","&"))
            Else
                  Response.Redirect("password.asp?result=loginfailed&target=" & Request.QueryString("target")) ) 'here's where I need to include the target url
            End If
      End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<link href="bibliography.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
}
-->
</style></head>
<br/>
<body>
<table border="0"><tr><td width="50">&nbsp;</td><td>
    <form action="password.asp?action=login&target=<%=Request.QueryString("target")%>" method="post">
            <% If Request.QueryString("result")="loginfailed" Then %>
                <p>Login failed. Please check that you have entered the correct password.</p>
            <% End If %>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="22%"><h1>Login</h1></td>
                <td width="78%">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" colspan="2">A password is required in order to request items from the AIM-VA Catalog. </td>
              </tr>
              <tr>
                <td height="44">Username: </td>
                <td><input type="text" id="txtUsername" name="txtUsername" /></td>
              </tr>
              <tr>
                <td height="44">Password: </td>
                <td><input type="password" id="txtPassword" name="txtPassword" /></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><input type="submit" id="btnLogin" name="btnLogin" value="Login" onclick="return ValidateLogin();" /></td>
                <td>&nbsp;</td>
              </tr>
            </table>
            <h2>&nbsp;</h2>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
    </form>
</td></tr></table>
</body>
</html>
0
 
LVL 82

Expert Comment

by:hielo
ID: 20313914
Corrections: misspelled username here:
Trim(Request.Form("txtUsename"))

and there is an extra/unmatched closing parenthesis here (which you need to remove):
Response.Redirect("password.asp?result=loginfailed&target=" & Request.QueryString("target")) ) 'here's where I need to include the target url
0
 

Author Comment

by:GessWurker
ID: 20315098
Thanks hielo. It's all working now!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Classic ASP error- Object required: 'objFolder' 6 39
Classic ASP - SQL Server connection problem 5 65
Help with stored procedure 30 64
SQL Server Web Traffic Limitations 4 60
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question