adding new user to the database
Hello:
I am having problem in adding new user registration to the database using ASP.What i want is when the user enter his personel information that information should be updated in the required database but it's giving me the following error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/begaspfiles/adduser1.asp, line 10
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Page:
POST 109 bytes to /begaspfiles/adduser1.asp
POST Data:
email=&GivenName=&FamilyName=&Address1=&Address2=& City=&State=&PostalCode=&Country=&Password=&Verify Password=
Here is the code that i am using to add the new user to the database.
file adduser1:
<%
Dim rsUsers
Set rsUsers = Server.CreateObject("ADODB.Recordset")
rsUsers.Open "newuser1", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
If Session("ID") <> "" Then ' currently logged-on user
rsUsers.Filter = "ID = '" & Session("ID") & "'"
Else ' New session
rsUsers.Filter = "EMailAddress = '" & Request.Form("email") & "'" & _
"AND Password = '" & Request.Form("password") & "'"
If rsUsers.EOF Then ' User not found
rsUsers.AddNew ' ...so add a new record
' Else
' Email address and password matched with DB records -
' In this case we'll allow this to update user's personal details
End If
End If
' write personal details to record
rsUsers("EMailAddress") = Request.Form("email")
rsUsers("Password") = Request.Form("password")
Dim strName, strValue ' create session variables
For each strField in rsUsers.Fields
strName = strField.Name
strValue = strField.value
Session(strName) = strValue
Next
Session("") = True ' declare that current user is validated
Response.Redirect "MenuForRegisteredUsers.asp"
%>
file Clssfd1:
<!-- METADATA TYPE="typelib"
FILE="D:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= D:\Inetpub\wwwroot\begaspfiles\newuser.mdb"
If Session("blnValidUser") = True and Session("ID") = "" Then
Dim rsIDCheck
Set rsIDCheck = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL = "SELECT ID FROM newuser1 " & _
"WHERE EMailAddress = '" & Session("EMailAddress") & "';"
rsPersonIDCheck.Open strSQL, objConn
If rsPersonIDCheck.EOF Then
Session("") = False
Else
Session("ID") = rsIDCheck("ID")
End If
rsIDCheck.Close
Set rsIDCheck = Nothing
End If
%>
file newuser:
<BASEFONT FACE="Arial" COLOR="#FFFFFF">
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function VerifyData()
{
if (document.frmUser.Password.value != document.frmUser.VerifyPassword.value)
{
alert ("Your passwords do not match - please reenter");
return false;
}
else
return true;
}
-->
</SCRIPT>
<TITLE>Banana Vehicle Parts - User Registration</TITLE>
</HEAD>
<BODY BGCOLOR="#000000">
<center>
<img name="n00000001" src="Banana_Motors1.jpg" width="756" height="172" border="0"
usemap="#m_00000001" alt=""><map name="m_00000001">
<area shape="rect" coords="668,153,721,165" href="http://chinese-jvzfdjb/begaspfiles/terms.asp"
target="_self" alt="" >
<area shape="rect" coords="538,153,614,165" href="http://chinese-jvzfdjb/begaspfiles/logoff.asp"
target="_self" alt="" >
<area shape="rect" coords="394,153,491,165"href="http://chinese-jvzfdjb/begaspfiles/checkout.asp"
target="_self" alt="" >
<area shape="rect" coords="256,153,375,165"
href="http://chinese-jvzfdjb/begaspfiles/catalog3.asp" target="_self" title="shop" alt="shop" >
<area shape="rect" coords="138,153,236,165"
href="http://chinese-jvzfdjb/begaspfiles/managecart.asp" target="_self" alt="" >
<area shape="rect" coords="37,153,80,165" href="http://chinese-jvzfdjb/begaspfiles/login.asp"
target="_self" alt="" >
</map>
</center>
<CENTER>
<img src="D:\Inetpub\wwwroot\begaspfiles\new.jpg">
<a href="http://chinese-jvzfdjb/begaspfiles/site_search.asp"><img
src="D:\Inetpub\wwwroot\begaspfiles\search.jpg" border="0"></a>
</CENTER>
<P>
<%
If Request("Update") = "True" Then
Response.Write "Please change your registration information as listed below<P>"
Else
If Request("NotFound") = "True" Then
Response.Write "<I>We were unable to locate your information. " & _
"Please take the time to register again.</I><P>"
End If
Response.Write "In order to use our services, please take a few minutes " & _
"to complete the form below. Once you have done that, " & _
"you will have full access to the system."
End If
%>
<FORM ACTION="adduser1.asp" NAME="frmUser" METHOD="POST"
onSubmit="return VerifyData()">
<TABLE BORDER=0>
<TR>
<TD WIDTH=20% ROWSPAN=11> </TD>
<TD>E-Mail Address:</TD>
<TD><INPUT TYPE="Text" NAME="email" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>Given Name:</TD>
<TD><INPUT TYPE="Text" NAME="GivenName" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>Family Name:</TD>
<TD><INPUT TYPE="Text" NAME="FamilyName" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>Address1:</TD>
<TD><INPUT TYPE="Text" NAME="Address1" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>Address2:</TD>
<TD><INPUT TYPE="Text" NAME="Address2" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>City:</TD>
<TD><INPUT TYPE="Text" NAME="City" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>State:</TD>
<TD><INPUT TYPE="Text" NAME="State" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>Postal Code:</TD>
<TD><INPUT TYPE="Text" NAME="PostalCode" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD>Country:</TD>
<TD><INPUT TYPE="Text" NAME="Country" VALUE=""
SIZE="40"></TD>
</TR>
<TR>
<TD> <P>Password:</TD>
<TD VALIGN=bottom><INPUT TYPE="password" NAME="Password"
VALUE="" SIZE="40"></TD>
</TR>
<TR>
<TD>Verify Password:</TD>
<TD><INPUT TYPE="Password" NAME="VerifyPassword" SIZE="40"></TD>
</TR>
<TR>
<TD></TD>
<TD ALIGN=CENTER COLSPAN=2><BR>
<INPUT TYPE="Submit" VALUE="Submit Registration">
<INPUT TYPE="RESET"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Please can anybody help me with this problem sooner.
Thankyou.
|