Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need ALOT of help!!!

Status
Not open for further replies.

Jesus4u

Programmer
Feb 15, 2001
110
US

Ok

With this code below what do I have to add to the code so I can check the userID in the Database to the strUserID and make sure there are no DUPLICATE UserID already in the DataBase?


Please help...this is the last area I need finished!

<!-- #INCLUDE FILE=&quot;data.asp&quot; -->
<% Response.Buffer = true %>
<%
'-- Check if Submit button pushed, if not ignore the entire script
If Request.Form(&quot;btnAdd&quot;) = &quot;Submit&quot; Then

'-- Make sure all boxes have data entered into them
If Request.Form(&quot;name&quot;) <> &quot;&quot; OR Request.Form(&quot;password&quot;) <> &quot;&quot; OR _
Request.Form(&quot;password2&quot;) <> &quot;&quot; OR _
Request.Form(&quot;email&quot;) <> &quot;&quot; OR _
Request.Form(&quot;userID&quot;) <> &quot;&quot; Then

'-- Make sure the passwords match
If Request.Form(&quot;password&quot;) = Request.Form(&quot;password2&quot;) Then

'-- Declare your variables
Dim DataConnection, cmdDC, RecordSet, SQL, strError
Dim strUserName, strPassword, strEmail, strUserID

'-- Get data from the form fields
strUserName = Request.Form(&quot;name&quot;)
strPassword = Request.Form(&quot;password&quot;)
strEmail = Request.Form(&quot;email&quot;)
strUserID = Request.Form(&quot;userID&quot;)


'-- Create object and open database
Set DataConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)
DataConnection.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot; & _
&quot;DBQ=&quot; & DatabasePath & &quot;;&quot;


Set cmdDC = Server.CreateObject(&quot;ADODB.Command&quot;)
cmdDC.ActiveConnection = DataConnection

'-- default SQL
SQL = &quot;SELECT * FROM UserRegistration&quot;

If Request.Form(&quot;name&quot;) <> &quot;&quot; Then
SQL = &quot;SELECT * FROM Register WHERE &quot; & _
&quot;Register.userID='&quot; & strUserID & &quot;' AND &quot; & _
&quot;Register.password ='&quot; & strPassword & _
&quot;' OR Register.email ='&quot; & strEmail & &quot;'&quot;
End If

cmdDC.CommandText = SQL
Set RecordSet = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'-- 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(&quot;email&quot;)=strEmail Then
Response.Redirect &quot;emailerror.asp&quot;
Else
Response.Redirect &quot;userpassworderror.asp&quot;
End If

Else
'-- Add new record to the database
Dim Dconn, sSQL
Set Dconn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Dconn.Open &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot; & _
DatabasePath & &quot;;&quot;

sSQL = &quot;INSERT INTO Register(name, email, userID, &quot; & _
&quot;password, userLevel) VALUES ('&quot; & strUserName & _
&quot;','&quot; & strEmail & &quot;','&quot; & strUserID & _
&quot;','&quot; & strPassword & &quot;',1)&quot;
Dconn.Execute sSQL
Dconn.Close
Set Dconn = Nothing


'Forward the user to page to notify of authentication
Response.Redirect &quot;thankyou.asp&quot;
End If
Else
Response.Redirect &quot;passworderror.asp&quot;
End If

'-- Close all connections
' RecordSet.Close
Set RecordSet = Nothing


' DataConnection.Close
Set DataConnection = Nothing


Else
'Tell them what they entered wrong
strError = &quot;Please fill in all the boxes&quot;
End If
End If


%>

<html>

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>New Page 1</title>
</head>

<body>

</body>

</html>




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top