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

Dani AI

Generated

Short practical plan: pick a proper database rather than a flat text file for anything beyond a quick toy. was right to insist on a users table. ’s text-file trick is okay for experiments, but it’s fragile and not secure. and demonstrate the basic query flow, but their examples use string concatenation — that works functionally but opens the app to SQL injection and usually implies storing plaintext passwords.

A minimal MySQL users table (create with phpMyAdmin or import the SQL):

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  password_hash VARCHAR(255) NOT NULL,
  email VARCHAR(100),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Authentication notes and a secure VB.NET pattern (use MySql.Data.MySqlClient or an appropriate provider). Always use parameterized commands and compare against a stored salted hash (bcrypt or PBKDF2), not plain text:

Using cmd = New MySqlCommand("SELECT password_hash FROM users WHERE username = @u", conn)
  cmd.Parameters.AddWithValue("@u", txtUser.Text)
  Using rdr = cmd.ExecuteReader()
    If rdr.Read() Then
      Dim storedHash = rdr.GetString(0)
      If VerifyPassword(txtPass.Text, storedHash) Then
        ' login success
      End If
    End If
  End Using
End Using

Practical tips: with XAMPP start Apache+MySQL and open phpMyAdmin to create/import the DB (myBB ships a database.sql that can be imported). Install the .NET MySQL connector to talk to MySQL from VB.NET. For single-file apps, SQLite (as suggested) is an easier alternative. Security checklist: never store plain passwords, use parameterized queries, hash+salt passwords, limit error detail on failed logins, close connections, and serve login forms over HTTPS. This ties together the thread answers and gives a secure path from a text-file prototype to a MySQL-backed login.

Recommended Answers

All 28 Replies

Are you storing the login credentials in database ?

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 .. :)

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

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?

please answer meeee

or tell me how to make 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.

commented: straight to the point +5

xampp has phpmyadmin, you can use it as a database..

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 ??

i have files saved in database.sql

Tell me first which data base you are using.

Is it MySQL or Ms Access ?

MySQL

what is that .mdb file you have mentioned ?

Even if he can, he needs to learn how to create a dbase himself.

Very true...

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

thanks for this code codeorder im gonna study each line

commented: Thanks for the credit and glad I could be of help. :) +10

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.