GessWurker
asked on
fix problem in simple asp login page; add username field
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
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"> </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%"> </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> </td>
<td> </td>
</tr>
<tr>
<td><input type="submit" id="btnLogin" name="btnLogin" value="Login" onclick="return ValidateLogin();" /></td>
<td> </td>
</tr>
</table>
<h2> </h2>
<p> </p>
<p> </p>
<p> </p>
</form>
</td></tr></table>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
dim targetUrl
If Request.Cookies("PasswordI sValidated ") = "true" Then
Response.Redirect(Replace( Request.Qu eryString( "target"), "gggAmPggg ","&"))
End If
If Request.QueryString("actio n")="login " Then
dim pwd
pwd = "password"
dim username
username = "username"
If pwd = Trim(Request.Form("txtPass word")) AND username = Trim(Request.Form("txtUsen ame")) Then
Response.Cookies("Password IsValidate d") = "true"
Response.Redirect(Replace( Request.Qu eryString( "target"), "gggAmPggg ","&"))
Else
Response.Redirect("passwor d.asp?resu lt=loginfa iled&targe t=" & Request.QueryString("targe t")) ) '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"> </td><td>
<form action="password.asp?actio n=login&ta rget=<%=Re quest.Quer yString("t arget")%>" method="post">
<% If Request.QueryString("resul t")="login failed" 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%"> </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> </td>
<td> </td>
</tr>
<tr>
<td><input type="submit" id="btnLogin" name="btnLogin" value="Login" onclick="return ValidateLogin();" /></td>
<td> </td>
</tr>
</table>
<h2> </h2>
<p> </p>
<p> </p>
<p> </p>
</form>
</td></tr></table>
</body>
</html>
<%
dim targetUrl
If Request.Cookies("PasswordI
Response.Redirect(Replace(
End If
If Request.QueryString("actio
dim pwd
pwd = "password"
dim username
username = "username"
If pwd = Trim(Request.Form("txtPass
Response.Cookies("Password
Response.Redirect(Replace(
Else
Response.Redirect("passwor
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"> </td><td>
<form action="password.asp?actio
<% If Request.QueryString("resul
<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 width="78%"> </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> </td>
<td> </td>
</tr>
<tr>
<td><input type="submit" id="btnLogin" name="btnLogin" value="Login" onclick="return ValidateLogin();" /></td>
<td> </td>
</tr>
</table>
<h2> </h2>
<p> </p>
<p> </p>
<p> </p>
</form>
</td></tr></table>
</body>
</html>
Corrections: misspelled username here:
Trim(Request.Form("txtUsen ame"))
and there is an extra/unmatched closing parenthesis here (which you need to remove):
Response.Redirect("passwor d.asp?resu lt=loginfa iled&targe t=" & Request.QueryString("targe t")) ) 'here's where I need to include the target url
Trim(Request.Form("txtUsen
and there is an extra/unmatched closing parenthesis here (which you need to remove):
Response.Redirect("passwor
ASKER
Thanks hielo. It's all working now!
ASKER