Current location: Hot Scripts Forums » Programming Languages » ASP » Searching through a database for a password


Searching through a database for a password

Reply
  #1 (permalink)  
Old 02-13-04, 01:41 PM
philkills philkills is offline
New Member
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Searching through a database for a password

hi, i have created a program that allows users to add a username and password as well as details about themselves to give them access to my programme.

All the usernames are stored in a database file and although when i first created the programme everything seemed fine it turned out that for some reason it is not recognising some of the usernames in the record so far it is only picking up usernames 1,2 and 4 out of 5. i have no idea why and it is quite frustating as i thought it was working.

anyway below is a copy of the code used to do this please if anyone can help i will be forever grateful =-)

Public Attempts As Integer
Public I As Integer

Private Sub cmdEnter_Click()
'original source for database as in college =N:\AVCE IT\Unit .programming\assigment\Prog.mdb
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\College WORK\Programming work\prog.mdb;Jet OLEDBatabase Password=1234", adOpenDynamic
Set rs = CreateObject("ADODB.Recordset")
StrSQL = "SELECT DISTINCT * FROM tblUsers ORDER BY UserID ASC"
rs.Open StrSQL, cn, adOpenDynamic
I = 0
Do While Not rs.EOF
If txtPassword.Text = rs("Password") And txtUserName.Text = rs("UserName") Then
MsgBox "Welcome " & rs("FirstName") & " " & rs("LastName"), 64, "Welcome to the games quiz"
Unload frmPass
frmwelcome.Show
Exit Sub
Else
I = I + 1
rs.Move (I)
End If
Loop
Attempts = Attempts - 1
MsgBox "Sorry the username or password you entered was invalid", 16, "Access Denied"
txtUserName.SetFocus
lblAttempts = "You have " & Attempts & " attempts remaining"
If Attempts = 0 Then
End
End If

End Sub
Reply With Quote
  #2 (permalink)  
Old 02-13-04, 08:25 PM
Stealth Stealth is offline
1337 pr0gr4mm3r
 
Join Date: Jun 2003
Location: Glasgow, Scotland
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
the problem is that uppercase and lowercase isnt compared, and its bad practice to loop through records to do a simple task such as checking a password


StrSQL = "SELECT USERNAME,PASSWORD FROM tblUsers WHERE USERNAME = '" & REPLACE(txtPassword.Text, "'", "''") & "' AND PASSWORD = '" & REPLACE(txtUserName.Text, "'", "''") & "'"
rs.Open StrSQL, cn, adOpenDynamic
IF RS.BOF OR RS.EOF THEN
'USERNAME OR PASSWORD IS WRONG
ELSE
'GIVE ACCESS
END IF
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
Share database over the Internet nitinkedia The Lounge 2 11-20-03 02:07 PM
Share database over the internet nitinkedia PHP 0 07-11-03 12:22 AM
Share database over the Internet nitinkedia New Members & Introductions 1 07-10-03 02:50 PM


All times are GMT -5. The time now is 04:11 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.