Hi,
I would like to display a message when a user fails to login to say, incorrect username or password. Its currently setup to redirect the user to the same login page on fail and even puts an error code attached to the login address.
I have also set up an absoluetely positioned div with the error message in it and the css style attached to this div is set to visibility ‘hidden’
My question is where in the code and how do I tell the div css to not be hidden so that the message appears when a user fails to login?
Thanks
Lloyd
[B]Javascript at top of page:
<%
// *** Validate request to log in to this site.
var MM_LoginAction = Request.ServerVariables(“URL”);
if (Request.QueryString != “”) MM_LoginAction += “?” + Server.HTMLEncode(Request.QueryString);
var MM_valUsername = String(Request.Form(“username”));
if (MM_valUsername != “undefined”) {
var MM_fldUserAuthorization = “”;
var MM_redirectLoginSuccess = ” index-1.asp”;
var MM_redirectLoginFailed = “index.asp?err=1”;
var MM_loginSQL = “SELECT username, Password”;
if (MM_fldUserAuthorization != “”) MM_loginSQL += “,” + MM_fldUserAuthorization;
MM_loginSQL += ” FROM dbo.tblMember WHERE username = ? AND Password = ?”;
var MM_rsUser_cmd = Server.CreateObject (“ADODB.Command”);
MM_rsUser_cmd.ActiveConnection = MM_iiGymConectionString_STRING;
MM_rsUser_cmd.CommandText = MM_loginSQL;
MM_rsUser_cmd.Parameters.Append(MM_rsUser_cmd.CreateParameter(“param1”, 200, 1, 50, MM_valUsername)); // adVarChar
MM_rsUser_cmd.Parameters.Append(MM_rsUser_cmd.CreateParameter(“param2”, 200, 1, 50, Request.Form(“password”))); // adVarChar
MM_rsUser_cmd.Prepared = true;
var MM_rsUser = MM_rsUser_cmd.Execute();
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match – this is a valid user
Session(“MM_Username”) = MM_valUsername;
if (MM_fldUserAuthorization != “”) {
Session(“MM_UserAuthorization”) = String(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value);
} else {
Session(“MM_UserAuthorization”) = “”;
}
if (String(Request.QueryString(“accessdenied”)) != “undefined” && false) {
MM_redirectLoginSuccess = Request.QueryString(“accessdenied”);
}
MM_rsUser.Close();
Response.Redirect(MM_redirectLoginSuccess);
}
MM_rsUser.Close();
Response.Redirect(MM_redirectLoginFailed);
}
%>
[B]HTML:
<div id=”loginerror”>Incorrect username or password</div>
[B]Style Sheet:
#loginerror {
position:absolute;
width:220px;
height:30px;
z-index:3;
top: 135px;
font-size: 12px;
color: #FF0000;
left: 15px;
font-weight: bold;
visibility: hidden;
}