I was wondering how can i make a working login form

What have i to put for user nae and password

Thanks in advanced
Mark

here.. i have some script for login form ..

Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
        connection()
        Try
            strcmd = New SqlClient.SqlCommand
            strcmd.Connection = koneksi
            strcmd.CommandText = "select * from tbl_user where ID = '" & t_id.Text & "' and password = '" & t_pass.Text & "'"

            login.DataSource = strcmd.ExecuteReader()

            If login.Count > 0 Then
                MessageBox.Show("Login success ..!)
                mainform.Show()
                t_id.Text = ""
                t_pass.Text = ""
                Me.Hide()
            Else
                MessageBox.Show("wrong username or passwd!")

            End If
        Catch ex As Exception
            MessageBox.Show("System Information", "error occurs on filling the username and password")
        End Try
    End Sub

submit this code in a command object ..
you can try .. :)

Edited 5 Years Ago by Nick Evan: Please put the code BETWEEN the 2 tags

koneksi.Open() 'open connection to server 
strcmd = New SqlClient.SqlCommand
strcmd.Connection = koneksi
            'this is the SQL select statement query that is performed
            ' to read the username and password from server 
strcmd.CommandText = "select * from tbl_user where ID = '" & t_id.Text & "' and password = '" & t_pass.Text & "'"

            Dim reader As SqlDataReader = strcmd.ExecuteReader

            If reader.Read Then
                 frmMain.Show'Display Application Main Form
                   Me.Dsipose 'use dispose instead of hide so you can clear all login form resources from memory


            Else
MessageBox.Show("invalid username or Password")
End if

Edited 5 Years Ago by Netcode: n/a

actually no i dont have database because i dont know how to make one but how can i make a txt file as a database?

i have a login form by fa3hed but i need a database please

Which database you plan to use ?

What ever the database is , create a table to store user_id, password and other required information.

ok look i have xammp how can i do a database for a forum please i have myBB
if you can tell me a tutorial site on how to do your own Forum then i can mark this topic as solved .

Thanks

ok look i have xammp how can i do a database for a forum please i have myBB
if you can tell me a tutorial site on how to do your own Forum then i can mark this topic as solved .

Thanks

I think debasisdas has given you the right answer. You need a plan to know the database you want to make use of and what you're good at. Any other thing requires further reading

i have done a forum but how can i find the database i need to use it with navicat but can really do it

i have done a forum but how can i find the database i need to use it with navicat but can really do it

Google it, there are tons of information about Databases..

You will never find any database online that caters to your exact requirement. So you need to design your own DB. Ans so far as log in concerned create a table to store user_id, password and other required information.You need to check for existence of userid/ password in the database. If it exists log in successful and allow the user to proceed further.

Comments
straight to the point

db.mdb this file was in the fa3hry's login form i have all the tables the admins one and the users one now how can i make such file like db.mdb with the tables that i have ??

MarkGia,

The easiest way I've found to do a login form with a database is using SQL Server 2008 Express with Management Studio and creating a table called users and then using a datareader to see if the table contains rows that match what a user is trying to use. If you need any help with this just let me know and I will give you a complete walkthrough.

Here's something using a .txt file.

codeorder:myCoolPassword

Save that text or any text in a file, mine is "C:\loginCredentials.txt".
Make sure you separate the username and password with a ":".

And for the code, see if this helps.
1 Button, 2 TextBoxes

Public Class Form1
    Private myLoginCredentialsFile As String = "C:\loginCredentials.txt"
    Private myFileContent As String = Nothing

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myLoginCredentialsFile) Then myFileContent = IO.File.ReadAllText(myLoginCredentialsFile) '// load File.
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text Like myFileContent.Substring(0, myFileContent.IndexOf(":")) Then '// check username.
            If TextBox2.Text Like myFileContent.Substring(myFileContent.IndexOf(":") + 1) Then '// check password.
            Else
                MsgBox("incorrect password")
                Exit Sub
            End If
        Else
            MsgBox("incorrect username")
            Exit Sub
        End If
        MsgBox("Login Successful")
    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.