Imports System.Data
Imports MySql.Data.MySqlClient
Public Class frmLogin
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim dtAdapter As New MySqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
strConnString = "Server=localhost;User Id=root; Password=1111; Database=1111; Pooling=false"
strSQL = "SELECT * FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & Me.txtPassword.Text & "' "
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
If dt.Rows(0)("Status").ToString.ToLower.Equals("vip") Then
Form3.Show()
Else
Form2.Show()
Me.Hide()
End If
Else
MsgBox("Username or Password Incorrect")
End If
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub
End Class
Imports System.Security.Cryptography
Imports System.Text
Public Function MD5(ByVal strString As String) As String
Dim ASCIIenc As New ASCIIEncoding
Dim strReturn As String
Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(strString)
Dim Md5Hash As New MD5CryptoServiceProvider
Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
For Each b As Byte In ByteHash
strReturn = strReturn & b.ToString("x2")
Next
Return strReturn
End Function
strSQL = "SELECT * FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & MD5(Me.txtPassword.Text) & "' "
Imports System.Security.Cryptography
Imports System.Text
Public Function MD5(ByVal strString As String) As String
Dim ASCIIenc As New ASCIIEncoding
Dim strReturn As String
Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(strString)
Dim Md5Hash As New MD5CryptoServiceProvider
Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)
For Each b As Byte In ByteHash
strReturn = strReturn & b.ToString("x2")
Next
Return strReturn
End Function
strSQL = "SELECT * FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & MD5(Me.txtPassword.Text) & "' "
Function EncMD5(ByVal input As String) As String
Dim md5Hashfc As MD5 = MD5.Create()
Dim data As Byte() = md5Hashfc.ComputeHash(Encoding.Default.GetBytes(input))
Dim sBuilder As New StringBuilder()
Dim i As Integer
For i = 0 To data.Length - 1
sBuilder.Append(data(i).ToString("x2"))
Next i
Return sBuilder.ToString()
End Function