Salam Blogger!!
Postingan kali ini ingin share tutorial cara membuat form ganti password. Mungkin kalian sudah sering menemukan form ganti password itu terdiri dari beberapa buah textbox. Misalnya, password lama, password baru n ulangi password baru.
Kalo yg seperti itu saya rasa sudah bosan, di sini saya buat sedikit berbeda tapi cara kerjanya hampir sama.
Oke..Begini hasil design ganti password yg sudah saya buat. Disini masih sederhana, kalian masih bisa kembangkan dengan kreatifitas masing-masing.
Oh ya sebagai catatan, saya menggunakan database PHP. Tapi bisa diterapkan dengan databse Acces maupun tanpa database sekalipun. Karena yang kita pelajari dari form ini adalah logikanya.
Tampilan form ganti passwordnya lebih simple bukan..
Ok. Untuk membuat sperti contoh di atas diperlukan minimal 3 buah textbox dan 2 comand button.
Ini listing programnya, silahkan disesuaikan penamaannya dengan yg Anda buat!
Private Sub batal_Click()
Me.password.Text = ""
Me.password.SetFocus
Me.plama.Text = "plama"
Me.pbaru.Text = "pbaru"
Me.Label1.Caption = "Masukan Password yg Lama"
Me.batal.Enabled = False
End Sub
Private Sub Command1_Click()
If Me.password.Text = "" Then
With MDIForm1
Unload Me
.tlogin.Enabled = False
.mnmaster.Enabled = True
.mntransaksi.Enabled = True
.mnlaporan.Enabled = True
.mnutility.Enabled = True
End With
Else
a = MsgBox("Data belum disimpan, yakin ingin keluar?", vbYesNo)
If a = vbYes Then
With MDIForm1
Unload Me
.tlogin.Enabled = False
.mnmaster.Enabled = True
.mntransaksi.Enabled = True
.mnlaporan.Enabled = True
.mnutility.Enabled = True
End With
End If
End If
End Sub
Private Sub Form_Activate()
Call koneksi
kon.CursorLocation = adUseClient
Me.password.SetFocus
Me.batal.Enabled = False
Me.Text1.Text = MDIForm1.StatusBar1.Panels(2)
End Sub
Private Sub password_Change()
Me.batal.Enabled = True
End Sub
Private Sub password_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Set rsadmin = kon.Execute("select password from admin where kode = '" & Me.Text1.Text & "'")
Me.Text2.Text = rsadmin!password
If Me.plama.Text = "plama" Then
If Me.password.Text = Me.Text2.Text Then
Me.plama.Text = Me.password.Text
Me.Label1.Caption = "Input password yg baru!"
Me.password.Text = ""
Me.password.SetFocus
Else
MsgBox "Password Salah!!"
Me.password.Text = ""
Me.password.SetFocus
End If
Else
If Me.password.Text = Me.plama.Text Then
MsgBox "Password Anda sama dengan yg lama" & Chr(13) & "Silahkan coba yg lain!"
Me.password.Text = ""
Me.password.SetFocus
ElseIf Me.pbaru.Text = "pbaru" Then
Me.pbaru.Text = Me.password.Text
Me.Label1.Caption = "Ulangi Password!"
Me.password.Text = ""
Me.password.SetFocus
Else
If Me.password.Text = Me.pbaru.Text Then
Set rsadmin = kon.Execute(" update admin set password = '" & Me.pbaru.Text & "'")
MsgBox "Password berhasil diubah"
Me.password.Text = ""
Me.password.SetFocus
Me.plama.Text = "plama"
Me.pbaru.Text = "pbaru"
Me.Label1.Caption = "Masukan Password yg Lama"
Me.batal.Enabled = False
Else
MsgBox "Password tidak sama!!"
Me.pbaru.Text = "pbaru"
Me.Label1.Caption = "Input password yg baru!"
Me.password.Text = ""
Me.password.SetFocus
End If
End If
End If
End If
End Sub
Semoga Bermanfaat,
0 comments:
Post a Comment