ASP Code Redirect Error
Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have the following problem: any suggestions?
I have a newuser login page that creates a new SQL DB table record with login name and password then takes the user to the next (page) step in the registration setup. Currently the record is created in the DB however the redirect doesn't occur. I get my asp message error (Msg = Msg & "An error occurred while creating the new account. " ) The following code is the newuser code:
<%
Option Explicit
on error resume next
Session("LoginN ame") = ""
Session("NewUse r") = True
dim adoCn
dim adoRs
dim SQL
dim Msg
dim TempChar
dim I
dim Account
dim Password
Account = trim(Request("t xtAccount"))
Password = trim(Request("t xtPassword1"))
Msg = ""
if len(Account) < 6 then
Msg = Msg & "The account name must be at least 6 characters long.<br>"
end if
if len(Password) < 6 then
Password = ""
Msg = Msg & "The password must be at least 6 characters long.<br>"
end if
for I = 1 to len(Account)
TempChar = asc(ucase(mid(A ccount, I , 1)))
if (((TempChar >= 48) and (TempChar <= 57)) or ((TempChar >= 65) and (TempChar <= 90))) = False then
Msg = Msg & "The account name you entered is invalid. "
Msg = Msg & "Please use only letters or numbers.<br>"
exit for
end if
next
for I = 1 to len(Password)
TempChar = asc(ucase(mid(P assword, I , 1)))
if (((TempChar >= 48) and (TempChar <= 57)) or ((TempChar >= 65) and (TempChar <= 90))) = False then
Password = ""
Msg = Msg & "The password you entered is invalid. "
Msg = Msg & "Please use only letters or numbers.<br>"
exit for
end if
next
if (Account <> "") and (Password <> "") then
if Password <> trim(Request("t xtPassword2")) then
Msg = Msg & "The retyped password is different than the first. "
Msg = Msg & "Please confirm the password.<br>"
else
SQL = "select * from tbRegistration "
SQL = SQL & "where (LoginName like '" & Account & "');"
set adoCn = Server.CreateOb ject("ADODB.Con nection")
adoCn.Open Session("SQLCon nect")
set adoRs = Server.CreateOb ject("ADODB.Rec ordset")
adoRs.Open SQL, adoCn, 1, 3
if adoRs.EOF then
adoRs.AddNew
adoRs("LoginNam e") = Account
adoRs("LoginPas sword") = Password
adoRs("DateRegi stered") = Date
adoRs("IsAdmin" ) = False
adoRs("RenewalA mount") = Session("Amount ")
adoRs.Update
else
Msg = Msg & "The account name you selected is already in use. "
Msg = Msg & "Please select another account name.<br>"
end if
adoRs.Close
adoCn.Close
set adoRs = Nothing
set adoCn = Nothing
if Err.Number <> 0 then
Err.Clear
Msg = Msg & "An error occurred while creating the new account. "
Msg = Msg & "Please try again.<br>"
end if
if Msg = "" then
Session("LoginN ame") = Account
Response.Redire ct("memreg.asp? mode=update")
Response.End
end if
end if
end if
%>
<html>
<head>
<title>New Member Account</title>
<meta name="Microsoft Border" content="l">
</head>
<form name="frmPost" method="POST" action="newuser .asp" onSubmit="retur n(Validate());" >
<table>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Acc ount Name:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="text" name="txtAccoun t" size="20" maxlength="20" value="<% =Account %>"></td>
</tr>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Pas sword:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="password" name="txtPasswo rd1" size="20" maxlength="20" value="<% =Password %>"></td>
</tr>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Ret ype Password:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="password" name="txtPasswo rd2" size="20" maxlength="20"> </td>
</tr>
</table>
<p><input type="submit" value="Next" name="btnNext"> </p>
</form>
<p><font face="Arial" size="2"><% =Msg %></font></p>
</td></tr>
</table>
</html>
<script LANGUAGE="javas cript">
<!--
function Validate() {
if (document.frmPo st.txtAccount.v alue.length < 6) {
alert("The account name must be at least 6 characters long.");
document.frmPos t.txtAccount.fo cus();
document.frmPos t.txtAccount.se lect();
return false;
}
if (!ValidateValue (document.frmPo st.txtAccount.v alue)) {
alert("The account name is invalid. Please enter only letters or numbers.");
document.frmPos t.txtAccount.fo cus();
document.frmPos t.txtAccount.se lect();
return false;
}
if (document.frmPo st.txtPassword1 .value.length < 6) {
alert("The password must be at least 6 characters long.");
document.frmPos t.txtPassword1. focus();
document.frmPos t.txtPassword1. select();
return false;
}
if (!ValidateValue (document.frmPo st.txtPassword1 .value)) {
alert("The password is invalid. Please enter only letters or numbers.");
document.frmPos t.txtPassword1. focus();
document.frmPos t.txtPassword1. select();
return false;
}
if (document.frmPo st.txtPassword1 .value != document.frmPos t.txtPassword2. value) {
alert("The retyped password does not match the first one.");
document.frmPos t.txtPassword2. focus();
document.frmPos t.txtPassword2. select();
return false;
}
return true;
}
function ValidateValue(I nputValue) {
var ValidChars = "ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz0123456 789";
var IsValid = true;
var CheckChar;
for (var i=0; i < InputValue.leng th; i++) {
CheckChar = "" + InputValue.subs tring(i, i+1);
if (ValidChars.ind exOf(CheckChar) == "-1") IsValid = false;
}
return IsValid;
}
-->
</script>
thanks,
dragiton
drag.it.on@hotm ail.com
Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have the following problem: any suggestions?
I have a newuser login page that creates a new SQL DB table record with login name and password then takes the user to the next (page) step in the registration setup. Currently the record is created in the DB however the redirect doesn't occur. I get my asp message error (Msg = Msg & "An error occurred while creating the new account. " ) The following code is the newuser code:
<%
Option Explicit
on error resume next
Session("LoginN ame") = ""
Session("NewUse r") = True
dim adoCn
dim adoRs
dim SQL
dim Msg
dim TempChar
dim I
dim Account
dim Password
Account = trim(Request("t xtAccount"))
Password = trim(Request("t xtPassword1"))
Msg = ""
if len(Account) < 6 then
Msg = Msg & "The account name must be at least 6 characters long.<br>"
end if
if len(Password) < 6 then
Password = ""
Msg = Msg & "The password must be at least 6 characters long.<br>"
end if
for I = 1 to len(Account)
TempChar = asc(ucase(mid(A ccount, I , 1)))
if (((TempChar >= 48) and (TempChar <= 57)) or ((TempChar >= 65) and (TempChar <= 90))) = False then
Msg = Msg & "The account name you entered is invalid. "
Msg = Msg & "Please use only letters or numbers.<br>"
exit for
end if
next
for I = 1 to len(Password)
TempChar = asc(ucase(mid(P assword, I , 1)))
if (((TempChar >= 48) and (TempChar <= 57)) or ((TempChar >= 65) and (TempChar <= 90))) = False then
Password = ""
Msg = Msg & "The password you entered is invalid. "
Msg = Msg & "Please use only letters or numbers.<br>"
exit for
end if
next
if (Account <> "") and (Password <> "") then
if Password <> trim(Request("t xtPassword2")) then
Msg = Msg & "The retyped password is different than the first. "
Msg = Msg & "Please confirm the password.<br>"
else
SQL = "select * from tbRegistration "
SQL = SQL & "where (LoginName like '" & Account & "');"
set adoCn = Server.CreateOb ject("ADODB.Con nection")
adoCn.Open Session("SQLCon nect")
set adoRs = Server.CreateOb ject("ADODB.Rec ordset")
adoRs.Open SQL, adoCn, 1, 3
if adoRs.EOF then
adoRs.AddNew
adoRs("LoginNam e") = Account
adoRs("LoginPas sword") = Password
adoRs("DateRegi stered") = Date
adoRs("IsAdmin" ) = False
adoRs("RenewalA mount") = Session("Amount ")
adoRs.Update
else
Msg = Msg & "The account name you selected is already in use. "
Msg = Msg & "Please select another account name.<br>"
end if
adoRs.Close
adoCn.Close
set adoRs = Nothing
set adoCn = Nothing
if Err.Number <> 0 then
Err.Clear
Msg = Msg & "An error occurred while creating the new account. "
Msg = Msg & "Please try again.<br>"
end if
if Msg = "" then
Session("LoginN ame") = Account
Response.Redire ct("memreg.asp? mode=update")
Response.End
end if
end if
end if
%>
<html>
<head>
<title>New Member Account</title>
<meta name="Microsoft Border" content="l">
</head>
<form name="frmPost" method="POST" action="newuser .asp" onSubmit="retur n(Validate());" >
<table>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Acc ount Name:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="text" name="txtAccoun t" size="20" maxlength="20" value="<% =Account %>"></td>
</tr>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Pas sword:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="password" name="txtPasswo rd1" size="20" maxlength="20" value="<% =Password %>"></td>
</tr>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Ret ype Password:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="password" name="txtPasswo rd2" size="20" maxlength="20"> </td>
</tr>
</table>
<p><input type="submit" value="Next" name="btnNext"> </p>
</form>
<p><font face="Arial" size="2"><% =Msg %></font></p>
</td></tr>
</table>
</html>
<script LANGUAGE="javas cript">
<!--
function Validate() {
if (document.frmPo st.txtAccount.v alue.length < 6) {
alert("The account name must be at least 6 characters long.");
document.frmPos t.txtAccount.fo cus();
document.frmPos t.txtAccount.se lect();
return false;
}
if (!ValidateValue (document.frmPo st.txtAccount.v alue)) {
alert("The account name is invalid. Please enter only letters or numbers.");
document.frmPos t.txtAccount.fo cus();
document.frmPos t.txtAccount.se lect();
return false;
}
if (document.frmPo st.txtPassword1 .value.length < 6) {
alert("The password must be at least 6 characters long.");
document.frmPos t.txtPassword1. focus();
document.frmPos t.txtPassword1. select();
return false;
}
if (!ValidateValue (document.frmPo st.txtPassword1 .value)) {
alert("The password is invalid. Please enter only letters or numbers.");
document.frmPos t.txtPassword1. focus();
document.frmPos t.txtPassword1. select();
return false;
}
if (document.frmPo st.txtPassword1 .value != document.frmPos t.txtPassword2. value) {
alert("The retyped password does not match the first one.");
document.frmPos t.txtPassword2. focus();
document.frmPos t.txtPassword2. select();
return false;
}
return true;
}
function ValidateValue(I nputValue) {
var ValidChars = "ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz0123456 789";
var IsValid = true;
var CheckChar;
for (var i=0; i < InputValue.leng th; i++) {
CheckChar = "" + InputValue.subs tring(i, i+1);
if (ValidChars.ind exOf(CheckChar) == "-1") IsValid = false;
}
return IsValid;
}
-->
</script>
thanks,
dragiton
drag.it.on@hotm ail.com
Comment