Use the module (mysql.bas) for connecting to the database.
A. The Login form (frmlogin.frm)
A.1 The Login form interface

A.2 The Login form code
Dim rs As ADODB.Recordset
Dim sql As String
Private Sub cmdClear_Click()
txtUsername.Text = ""
txtPassword.Text = ""
End Sub
Private Sub cmdLogin_Click()
sql = "select * from tbsignup where username = '" & txtUsername.Text & "' and password = '" & txtPassword.Text & "'"
Set rs = db.Execute(sql)
If Len(txtUsername.Text) = 0 Then
MsgBox "Please type your user name.", vbOKOnly + vbInformation, "Message"
Exit Sub
ElseIf Len(txtPassword.Text) = 0 Then
MsgBox "Please type your password.", vbOKOnly + vbInformation, "Message"
Exit Sub
ElseIf (rs.RecordCount <> 0) Then
frmMain.Show
username = txtUsername.Text
Unload Me
Else
MsgBox "Account does not exist", vbOKOnly + vbInformation, "Message"
End If
End Sub
Private Sub cmdSignup_Click()
frmSignup.Show
Unload Me
End Sub
Private Sub Form_Load()
Call SetConnection("localhost", "dbslumbook", "root", "OtlPHP07")
Call cmdClear_Click
End Sub
B. The Signup Form (frmSignup.frm)
B.1 The Signup Form Interface

B.2 The Signup Form Code
Dim rs As ADODB.Recordset
Private Sub cmdClear_Click()
txtUsername.Text = ""
txtPassword.Text = ""
txtconfirm.Text = ""
End Sub
Private Sub cmdLogin_Click()
Dim blnrequired As Boolean
Dim message As String
message = "Please Fill up the following fields: "
If Len(txtUsername.Text) = 0 Then
message = message & " Username "
blnrequired = True
End If
If Len(txtPassword.Text) = 0 Then
message = message & " Password "
blnrequired = True
End If
If blnrequired = True Then
MsgBox message
Exit Sub
End If
sql = "insert into tbsignup(username,password) values ('" & txtUsername & "','" & txtPassword & "')"
Set rs = db.Execute(sql)
MsgBox "Account created", vbOKOnly + vbInformation, "Message"
End Sub
Private Sub cmdLogin_Click()
frmLogin.Show
Unload Me
End Sub
Private Sub Form_Load()
Call SetConnection("localhost", "dbslumbook", "root", "OtlPHP07")
Call cmdClear_Click
End Sub
Test this Login and Signup form yourself
2 comments:
Private Sub Form_Load()
Call SetConnection("localhost", "dbslumbook", "root", "OtlPHP07")
Call cmdClear_Click
End Sub
paanu paganahin poh yan sir...nid asap..tnx
Change dbslumbook to the name of your database. Change root to the username of your database server. Change OtlPHP07 to the password of your database
Post a Comment