database check

Results 1 to 2 of 2

Thread: database check

  1. #1
    Join Date
    Dec 1969

    Default database check

    I am trying to run a check on the database where if the username or password are already taken, it will redirect the person back to that page to input a new name and password. Where did i go wrong with this coding?<BR><BR>&#060;% Option Explicit %&#062;<BR>&#060;% Response.buffer = True %&#062;<BR><BR>&#060;%<BR>Dim dbObj, DatabaseConn, SQL<BR><BR>Set DatabaseConn = Server.CreateObject("ADODB.Connection") <BR>Set dbObj = Server.CreateObject("ADODB.Recordset") <BR><BR>DatabaseConn.Open "DSN=auditionamerica;DRIVER={SQL Server};UID=sa"<BR><BR>SQL = "SELECT * FROM users where Username &#060;&#062; &#039;" & Request.form("username") & "&#039; AND Password &#060;&#062; &#039;" & Request.form("password") & "&#039;"<BR><BR>dbObj.Open SQL, DatabaseConn, 3, 3<BR><BR>If Not dbObj.EOF then<BR>response.redirect "auditioneeusername.asp"<BR><BR>else <BR><BR>response.redirect "eenamewrite.asp"<BR>end if<BR>%&#062;

  2. #2
    Eddie Campbell Guest

    Default RE: database check

    As you are selecting all users who do NOT ahve the same name and password as the newly entered one, you will ALLWAYS get data back (assuming you have at least 2 user names in your database).<BR><BR>Try selecteing records WITH EITHER the same name OR PW and then if the recordset is empty, you know the name/password has NOT been used, otherwise you know that it has.<BR><BR>But are you sure that you don&#039;t want to allow 2 users to use the same password if their login name is different?<BR><BR>SQL = "SELECT * FROM users where Username = &#039;" & Request.form("username") & "&#039; OR Password = &#039;" & Request.form("password") & "&#039;"<BR><BR>...<BR>if dbObj.EOF then<BR> OK to add the the new user<BR>else<BR> Get them to enter new name/password<BR>End if

Posting Permissions

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