
registration form check and Enter into database produces server 500 error
the following is what ive been trying.
Create a registration form, first have the required fields be checked by
Client script.
If they are ok, then post the form, and some serverside script enter the
stuff into the database(Access2000). It's a fairly long procedure
If there is a much easier way f doing it, then id appreciate the info about
it.
Hard thing about this page, is that the entire messageboard action
(register, login, post, edit etc) takes place in the same file. (index.asp)
,. Its working for a large part through includes, depending on the
QueryString..
The following is show in the browser if the QueryString("id")="register"
========================================================
<%
' Define Connection variables and Required-field variables
' the Reg is added after cn and rs, cos i use multiple recordsets in the
index file. naming them all cn and rs
' will give an ASP compilation error.And this helps keeping the
recordsets apart.
Dim cnReg
Dim rsReg
Dim strUsername
Dim strPassword
Dim strEmail
Dim strStatus
' Stuff the required-field variables with the Form-data
' I dont have to check these(are they filled out or not), cos a
clientside script has allready done that.
strUsername = request.Form("txtUsername")
strPassword = request.Form("txtPassword")
strEmail = request.Form("txtEmail")
strStatus = request.Form("txtStatus")
' Check whether optional fields are filled out.
' If they are, build and define a variable for them
If request.Form("txtFname")<>"" Then
Dim strFname
strFname = request.Form("txtFname")
End If
If request.Form("txtLname")<>"" Then
Dim strLname
strLname = request.Form("txtLname")
End if
If request.Form("txtAddress")<>"" Then
Dim strAddress
strAddress = request.Form("txtAddress")
End if
If request.Form("txtZip")<>"" Then
Dim strZip
strZip = request.Form("txtZip")
End if
If request.Form("txtCity")<>"" Then
Dim strCity
strCity = request.Form("txtCity")
End if
If request.Form("txtProvince")<>"" Then
Dim strProvince
strProvince = request.Form("txtProvince")
End if
If request.Form("txtCountry")<>"" Then
Dim strCountry
strCountry = request.Form("txtCountry")
End if
If request.Form("txtNotes")<>"" Then
Dim strNotes
strNotes = request.Form("txtNotes")
End if
If request.Form("txtICQ")<>"" Then
Dim strIcq
strIcq = request.Form("txtICQ")
End if
If request.Form("txtUrl")<>"" Then
Dim strUrl
strUrl = request.Form("txtUrl")
End if
' Open ADO recordset
Set cnReg = Server.CreateObject("ADODB.Connection")
Set rsReg = Server.CreateObject("ADODB.Recordset")
cnReg.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=E:\Path\to\db\forum.mdb;"
rsReg.CursorType = adOpenKeyset
rsReg.LockType = adLockOptimistic
rsReg.Source = "user"
rsReg.ActiveConnection = cnReg
rsReg.Open
' Construct the fields to be added to the database (required fields).
rsReg.AddNew
rsReg.Fields("user") = strUsername
rsReg.Fields("pass") = strPassword
rsReg.Fields("status") = strStatus
rsReg.Fields("email") = strEmail
' Construct the fields to be added to the database (Optional fields).
If request.Form("txtFname")<>"" Then
rsReg.Fields("fname") = strFname
End If
If request.Form("txtLname")<>"" Then
rsReg.Fields("lnamr") = strLname
End If
If request.Form("txtAddress")<>"" Then
rsReg.Fields("address") = strAddress
End If
If request.Form("txtZip")<>"" Then
rsReg.Fields("zip") = strZip
End If
If request.Form("txtProvince")<>"" Then
rsReg.Fields("province") = strProvince
End If
If request.Form("txtCity")<>"" Then
rsReg.Fields("city") = strCity
End If
If request.Form("txtCountry")<>"" Then
rsReg.Fields("country") = strCountry
End If
If request.Form("txtNotes")<>"" Then
rsReg.Fields("notes") = strNotes
End If
If request.Form("txtICQ")<>"" Then
rsReg.Fields("icq") = strIcq
End If
If request.Form("txtUrl")<>"" Then
rsReg.Fields("url") = strUrl
End If
' Execute the update and set a session variable
rsReg.Update
Session("ForumReg")=strUsername
' Clean up and redirect.
rsReg.Close
cnReg.Close
Set rsReg = Nothing
Set cnReg = Nothing
response.redirect("index.asp?id=RegSuccess")
%>
===============================================================
This code produces the Server 500 error. When I receive ASP Compile errors,
it gives me linenumbers and error descriptions in return, but a server 500
doesnt tell me anything usefull about the error. Can anyone give a push in
the right direction or possibly have the answer?
Thanx very much in advance =)
Jim