I need serious help with my software. Im making a system for an election. I need to make a login which reads and identifies text from the text file and if it is the correct user name and password in the textboxes then it opens another form. I have to make a textfile which will allow various users to login. Im currently using vb 2010. Thanks
You are in luck! I have just made my own system :)
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
If (My.Computer.FileSystem.FileExists("C:\ProgramData\Hax Client\User Data\Temp Users\" + txtUsername.Text + ".txt")) Then
ElseIf (My.Computer.FileSystem.FileExists("C:\ProgramData\Hax Client\User Data\" + txtUsername.Text + ".txt")) Then
Using sr As New StreamReader("C:\ProgramData\Hax Client\User Data\" + txtUsername.Text + ".txt")
While Not sr.EndOfStream
Dim unpw() As String = sr.ReadLine.Split("|")
'example is username|password
'our array is now unpw(0) = username
' unpw(1) = password
If txtUsername.Text = unpw(0) And txtPassword.Text = unpw(1) Then
'sucess
'Loads new form once correct details have been entered
If (unpw(0) = "guest" And unpw(1) = "guest") Then
Dim GuestWindow As New GuestWindow
GuestWindow.Show()
Me.Close()
Else
Dim MainWindow As New MainWindow
MainWindow.Show()
Me.Close()
End If
End If
End If
End While
End Using
Else
My.Computer.FileSystem.WriteAllText("C:\ProgramData\Hax Client\User Data\Temp Users\" + txtUsername.Text + ".txt", "Failed Login! Used username: " + txtUsername.Text, False)
End If
End Sub
Now the way I made mine work was in "C:\\ProgramData\\Hax Client\\Users\\.txt"
Text file:
<username>|<password>
Just name the textfile as the username for simplicity. You could try encoding them? But i'm not sure how.
Anyways if you need anymore help just reply :) Also within the Users folder I made \\Temp Users this is where failed logins go, and then are cleared once logged in. Its to stop the coding from crashing.
Skype: nfell2009
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.