
-----------------------------------
krikor0322
Mon May 03, 2004 5:27 pm

Registering / Logging in
-----------------------------------
Hello everyone...
         I need to know how to register a username and a password, store it in a bin file or a txt file, and then logging in with the username and password u just registered... if anyone knows how to do it let me know... thanx alot..  :D

-----------------------------------
krikor0322
Mon May 03, 2004 5:29 pm

BTW
-----------------------------------
I forgot to mention i need this done in VB thanks alot again..

-----------------------------------
Brightguy
Mon May 03, 2004 7:53 pm

Re: Registering / Logging in
-----------------------------------
I wrote this really fast, but I tested it and it worked fine.  It's just a really simple "username register".  It stores the users in a .txt file in the same directory as the application.

To use it, place two Text Boxes (#1 for username, #2 for password) and two Command Buttons on a form (#1 to log in, #2 to register new users).

Private Type UserData
    Username As String * 30
    Password As String * 30
End Type

Private Sub Command1_Click()
    Dim FileIn As Integer
    Dim CurrentUser As UserData, CheckUser As UserData
    FileIn = FreeFile
    Open App.Path & "\users.txt" For Random As #FileIn Len = Len(CheckUser)
    
    CurrentUser.Username = Text1.Text
    CurrentUser.Password = Text2.Text
    
    Do While Not EOF(FileIn)
        Get #FileIn, , CheckUser
        If CurrentUser.Username = CheckUser.Username And CurrentUser.Password = CheckUser.Password Then
            MsgBox "Successfully Logged In"
            Close #FileIn
            Exit Sub
        End If
    Loop
    
    MsgBox "Unsuccessfully Logged In"
    Close #FileIn
End Sub

Private Sub Command2_Click()
    Dim FileOut As Integer
    Dim SaveUser As UserData
    FileOut = FreeFile
    Open App.Path & "\users.txt" For Random As #FileOut Len = Len(SaveUser)
    
    SaveUser.Username = Text1.Text
    SaveUser.Password = Text2.Text
    
    Put #FileOut, LOF(FileOut) / Len(SaveUser) + 1, SaveUser    'Append userdata to file
    
    MsgBox "Successfully Registered"
    Close #FileOut
End Sub

-----------------------------------
krikor0322
Mon May 03, 2004 8:05 pm

wow
-----------------------------------
Thanks alot man... I really appreciate it...
