Recover Your Password From System.

Thursday, 30 June 2011
This Post Will Show You How To Create A Application That Will Recover Your Password From The Database Using The Secret Question..
Steps To create:
Step 1:
  • Create Login Page As In Image Below.
  •   Code For Above Page.
Declaration: 

     Dim provider As String = "Provider=Microsoft.jet.OLEDB.4.0;"
     Dim path As String = "Data Source=" & Application.StartupPath & "\login.mdb;"
     Public con As New OleDbConnection(provider & path)

Login Button:

        Dim cmd As New OleDbCommand
        cmd = New OleDbCommand("select  * from Login", con)
        Try
            cn.Open()
            Dim dr As OleDbDataReader
            Dim user, pass, ut As String
            ut = "Administrator"
            dr = cmd.ExecuteReader
            While dr.Read
                   user = dr("Username")
                   pass = dr("password")
                   If TextBox1.Text = user And TextBox2.Text = pass Then
                     MsgBox("Login Successful By Username : '" & TextBox1.Text & "' As '" & ut & "'")
                   Else
                     MsgBox("User name or password is wrong")
                   End If
            End While
            dr.Close()
            con.Close()
        Catch ex As Exception
        End Try
ForgotPassword Button:
        forgot.Show()
        Me.Hide()

Step 2:
  • When You Click On ForgotPassword Button It Will Open Following Form.

  •  Code For Above Page.
Declaration:
Dim cn As OleDbConnection = login.con
ValidateUsername Button:
         Try
            If flag = 0 Then
                If txtusername.Text = "" Then
                    MsgBox("please enter username")
                Else
                    flag = 1
                    btnvalshow.Text = "Show Password"
                    Dim cmd As New OleDbCommand
                    cmd = New OleDbCommand("select  que from secured WHERE Username='" & txtusername.Text & "'", cn)
                    con.Open()
                    Dim dr As OleDbDataReader
                    Dim q As String
                    'ut = "Administrator"
                    dr = cmd.ExecuteReader
                    While dr.Read
                        q = dr(0)
                        Label4.Text = q
                    End While
                    con.Close()
                End If
            End If

            If flag = 1 Then
                If txtanswer.Text = "" Then
                    MsgBox("Enter Answer")
                Else
                    Dim cmd As New OleDbCommand
                    cmd = New OleDbCommand("select  * from secured ", con)
                    con.Open()
                    Dim dr As OleDbDataReader
                    Dim user, pass, a, q As String
                    'ut = "Administrator"
                    dr = cmd.ExecuteReader
                    While dr.Read
                        user = dr(0)
                        pass = dr(1)
                        q = dr(2)
                        a = dr(3)
If txtusername.Text = user And txtanswer.Text = a Then
MsgBox("Password for Username : '" & txtusername.Text & "' PASSWORD :  '" & pass & "'")
                        Else
MsgBox("User name is not found")
                        End If
                    End While
                    dr.Close()
                    con.Close()
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
            con.Close()
        End Try
  • Set flag=0 on FormLoad Of Second Form....

0 comments:

Post a Comment