jesus4u
Feb 14th, 2001, 08:18 AM
Forgive me I also posted this in another forum but I really need help fast.
Ok..Here is the code. I sampled this from someone else on the web. You know... free code.
My problem is that it doesn't DO what it it supposed to do.
It doesn't end up checking for empty fields or check for passwords to match nor does it write into the DB. Why am I not making connection into the DB?
ANy ideas???
I am using a simple Access database within the domain. I used Frontpage 2000 as my editor.
I really need this finished today.PLease help me.
<!-- #INCLUDE FILE="data.asp" --> 'code for this file is below
<% Response.Buffer = true %>
<%
'-- Check if Submit button pushed, if not ignore the entire script
If Request.Form("btnAdd") = "Submit" Then
'-- Make sure all boxes have data entered into them
If Request.Form("name") <> "" OR Request.Form("password") <> "" OR _
Request.Form("password2") <> "" OR _
Request.Form("email") <> "" OR _
Request.Form("userID") <> "" Then
'-- Make sure the passwords match
If Request.Form("password") = Request.Form("password2") Then
'-- Declare your variables
Dim DataConnection, cmdDC, RecordSet, SQL, strError
Dim strUserName, strPassword, strEmail, strUserID
'-- Get data from the form fields
strUserName = Request.Form("name")
strPassword = Request.Form("password")
strEmail = Request.Form("email")
strUserID = Request.Form("userID")
'-- Create object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & DatabasePath & ";"
Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConnection
'-- default SQL
SQL = "SELECT * FROM UserRegistration"
If Request.Form("name") <> "" Then
SQL = "SELECT UserRegistration.* FROM UserRegistration WHERE " & _
"UserRegistration.userID='" & strUserID & "' AND " & _
"UserRegistration.password ='" & strPassword & _
"' OR Register.email ='" & strEmail & "'"
End If
cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject("ADODB.Recordset")
'-- Cursor Type, Lock Type
'-- ForwardOnly 0 - ReadOnly 1
'-- KeySet 1 - Pessimistic 2
'-- Dynamic 2 - Optimistic 3
'-- Static 3 - BatchOptimistic 4
RecordSet.Open cmdDC, , 0, 2
'-- check to see if the user and password or
' e-mail address have registered before
If Not RecordSet.EOF Then
If RecordSet.fields("email")=strEmail Then
strError = "<FONT FACE='ARIAL' SIZE='2'><B>" & _
"Sorry this email has already been " & _
"registered, please try again" & _
"</B></FONT>"
Else
'Redo page and say that this User name
'and Password are already taken
strError = "<FONT FACE='ARIAL' SIZE='2'><B>" & _
"Sorry this user name and password are " & _
"already taken, please try again" & _
"</B></FONT>"
End If
Else
'-- Add new record to the database
Dim Dconn, sSQL
Set Dconn = Server.CreateObject("ADODB.Connection")
Dconn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _
DatabasePath & ";"
sSQL = "INSERT INTO UserRegistration(name, email, userID, " & _
"password, userLevel) VALUES ('" & strUserName & _
"','" & strEmail & "','" & strUserID & _
"','" & strPassword & "',1)"
Dconn.Execute sSQL
Dconn.Close
Set Dconn = Nothing
'Forward the user to page to notify of authentication
Response.Redirect "thankyou.asp"
End If
Else
strError = "Your passwords don't match"
End If
'-- Close all connections
RecordSet.Close
Set RecordSet = Nothing
DataConnection.Close
Set DataConnection = Nothing
Else
'Tell them what they entered wrong
strError = "Please fill in all the boxes"
End If
End If
%>
<!-- HTML FORM -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<BODY bgcolor="#FFFFFF" MARGINHEIGHT="0" MARGINWIDTH="0"
LEFTMARGIN="0" TOPMARGIN="0" TEXT="#000000">
<%
'-- Error message if there is any
Response.write (strError & "<BR>")
%>
<form method="POST" action="thankyou.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1">
<!--webbot bot="SaveDatabase" SuggestedExt="asp"
S-DataConnection="UserRegistration" S-RecordSource="Register"
U-Database-URL="fpdb/UserRegistration.mdb"
S-Builtin-Fields="HTTP_USER_AGENT REMOTE_HOST Timestamp REMOTE_USER"
S-Builtin-DBFields="Browser_type Remote_computer_name Timestamp User_name"
S-Form-Fields="password2 userID email password name"
S-Form-DBFields="PASSWORD2 USERID email PASSWORD Name" -->
<div align="left">
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td width="50%"><font face="Arial" size="2">Full
Name:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="text" name="name" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Email:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a User ID:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="text" name="userID" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a Password:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Confirm
Password:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="password" name="password2" size="20"></td>
</tr>
</table>
</div>
<p><input type="submit" value="Submit" name="btnAdd">
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
----------------------------------------------------
data.asp
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<%
Const DatabasePath = "c:/inetpub/wwwroot/ReclaimAmerica.org/fpdb/UserRegistration.mdb"
%>
<P> </P>
</BODY>
</HTML>
Ok..Here is the code. I sampled this from someone else on the web. You know... free code.
My problem is that it doesn't DO what it it supposed to do.
It doesn't end up checking for empty fields or check for passwords to match nor does it write into the DB. Why am I not making connection into the DB?
ANy ideas???
I am using a simple Access database within the domain. I used Frontpage 2000 as my editor.
I really need this finished today.PLease help me.
<!-- #INCLUDE FILE="data.asp" --> 'code for this file is below
<% Response.Buffer = true %>
<%
'-- Check if Submit button pushed, if not ignore the entire script
If Request.Form("btnAdd") = "Submit" Then
'-- Make sure all boxes have data entered into them
If Request.Form("name") <> "" OR Request.Form("password") <> "" OR _
Request.Form("password2") <> "" OR _
Request.Form("email") <> "" OR _
Request.Form("userID") <> "" Then
'-- Make sure the passwords match
If Request.Form("password") = Request.Form("password2") Then
'-- Declare your variables
Dim DataConnection, cmdDC, RecordSet, SQL, strError
Dim strUserName, strPassword, strEmail, strUserID
'-- Get data from the form fields
strUserName = Request.Form("name")
strPassword = Request.Form("password")
strEmail = Request.Form("email")
strUserID = Request.Form("userID")
'-- Create object and open database
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & DatabasePath & ";"
Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConnection
'-- default SQL
SQL = "SELECT * FROM UserRegistration"
If Request.Form("name") <> "" Then
SQL = "SELECT UserRegistration.* FROM UserRegistration WHERE " & _
"UserRegistration.userID='" & strUserID & "' AND " & _
"UserRegistration.password ='" & strPassword & _
"' OR Register.email ='" & strEmail & "'"
End If
cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject("ADODB.Recordset")
'-- Cursor Type, Lock Type
'-- ForwardOnly 0 - ReadOnly 1
'-- KeySet 1 - Pessimistic 2
'-- Dynamic 2 - Optimistic 3
'-- Static 3 - BatchOptimistic 4
RecordSet.Open cmdDC, , 0, 2
'-- check to see if the user and password or
' e-mail address have registered before
If Not RecordSet.EOF Then
If RecordSet.fields("email")=strEmail Then
strError = "<FONT FACE='ARIAL' SIZE='2'><B>" & _
"Sorry this email has already been " & _
"registered, please try again" & _
"</B></FONT>"
Else
'Redo page and say that this User name
'and Password are already taken
strError = "<FONT FACE='ARIAL' SIZE='2'><B>" & _
"Sorry this user name and password are " & _
"already taken, please try again" & _
"</B></FONT>"
End If
Else
'-- Add new record to the database
Dim Dconn, sSQL
Set Dconn = Server.CreateObject("ADODB.Connection")
Dconn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _
DatabasePath & ";"
sSQL = "INSERT INTO UserRegistration(name, email, userID, " & _
"password, userLevel) VALUES ('" & strUserName & _
"','" & strEmail & "','" & strUserID & _
"','" & strPassword & "',1)"
Dconn.Execute sSQL
Dconn.Close
Set Dconn = Nothing
'Forward the user to page to notify of authentication
Response.Redirect "thankyou.asp"
End If
Else
strError = "Your passwords don't match"
End If
'-- Close all connections
RecordSet.Close
Set RecordSet = Nothing
DataConnection.Close
Set DataConnection = Nothing
Else
'Tell them what they entered wrong
strError = "Please fill in all the boxes"
End If
End If
%>
<!-- HTML FORM -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<BODY bgcolor="#FFFFFF" MARGINHEIGHT="0" MARGINWIDTH="0"
LEFTMARGIN="0" TOPMARGIN="0" TEXT="#000000">
<%
'-- Error message if there is any
Response.write (strError & "<BR>")
%>
<form method="POST" action="thankyou.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1">
<!--webbot bot="SaveDatabase" SuggestedExt="asp"
S-DataConnection="UserRegistration" S-RecordSource="Register"
U-Database-URL="fpdb/UserRegistration.mdb"
S-Builtin-Fields="HTTP_USER_AGENT REMOTE_HOST Timestamp REMOTE_USER"
S-Builtin-DBFields="Browser_type Remote_computer_name Timestamp User_name"
S-Form-Fields="password2 userID email password name"
S-Form-DBFields="PASSWORD2 USERID email PASSWORD Name" -->
<div align="left">
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td width="50%"><font face="Arial" size="2">Full
Name:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="text" name="name" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Email:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a User ID:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="text" name="userID" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Choose
a Password:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td width="50%"><font face="Arial" size="2">Confirm
Password:</font></td>
<td width="50%"><!--webbot bot="Validation" B-Value-Required="TRUE"
--><input type="password" name="password2" size="20"></td>
</tr>
</table>
</div>
<p><input type="submit" value="Submit" name="btnAdd">
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
----------------------------------------------------
data.asp
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<%
Const DatabasePath = "c:/inetpub/wwwroot/ReclaimAmerica.org/fpdb/UserRegistration.mdb"
%>
<P> </P>
</BODY>
</HTML>