Results 1 to 3 of 3

Thread: I am Falling HELP

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Unhappy

    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="data.asp" -->
    <% 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 * FROM Register WHERE " & _
    "Register.userID='" & strUserID & "' AND " & _
    "Register.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
    Response.Redirect "emailerror.asp"
    Else
    Response.Redirect "userpassworderror.asp"
    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 Register(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
    Response.Redirect "passworderror.asp"
    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>

    <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>

    </body>

    </html>

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Do until rs.eof
    If rs("email") = request.form("email") or rs("userid") = request.form("userid") Then
    previoususer = "True"
    Exit Do
    End If
    Loop

    If previoususer = "True" Then
    response.write "User already in database"
    Else:
    'Your add to database code
    end If


    Does this help??
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    OOpps one mistake
    Code:
    Do until rs.eof 
       If rs("email") = request.form("email") or rs("userid") = request.form("userid") Then 
           previoususer = "True" 
           Exit Do 
       End If 
       rs.movenext
    Loop 
    
    If previoususer = "True" Then 
       response.write "User already in database" 
    Else: 
       'Your add to database code 
    end If
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width