php,VB- mysql
dobry den , vytvoril sem si registraci ve stylu php,mysql
viz.
http://bhacks-registration.atwebpages.com/login.ph p
(vse se zapisuje to mysql database....
a chctel bych vytvorit program ve Visual basicu
pres ktery by se lidi mohly prihlasit ...
nekde sem nasel tenhle kod
.
.
.
Imports MySql.Data.MySqlClient
Public Class Form1
Dim conn As New MySqlConnection
Private Function Connect(ByVal server As String, ByRef user As String, ByRef password As String, ByRef database As String)
'We make here the connection string
conn.ConnectionString = "server=" + server + ";" _
& "user id=" + user + ";" _
& "password=" + password + ";" _
& "database=" + database + ";"
Try
'Try to open the connection
conn.Open()
Return True
Catch ex As MySqlException
'If fail will show a MySQL Error
Return MsgBox(ex.Message)
End Try
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Host User Pass Database
Connect("localhost", "root", "", "vblogin") 'Change the host user and password.
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myData As MySqlDataReader
Dim SQL As String
'Our MySQL Query
Dim Email As String = txtEmail.Text.Replace("'", "\'")
Dim Password As String = txtPassword.Text.Replace("'", "\'")
SQL = "SELECT * FROM `users` WHERE `email` = '" + Email + "' AND `password` = '" + Password + "'"
myCommand.Connection = conn
myCommand.CommandText = SQL
myAdapter.SelectCommand = myCommand
Try
'Try to execute the query
myData = myCommand.ExecuteReader()
myData.Read()
If myData.HasRows = 0 Then 'Checkes if a row with the email and password exist.
'If no outputs this:
MsgBox("Email and Password dont match!.")
myData.Close()
Else
'if yes outputs this:
MsgBox("Welcome " + myData.GetString("fname") + "!.")
myData.Close()
End If
Catch ex As MySqlException
'If fail outputs MySQL Error
MsgBox(ex.Message)
End Try
End Sub
End Class
ale jakmile kliknu na tlacitko "Debug" tak se mi cely pc zamrzne . :(co stim ...?
jestly neco nechapete tak napiste co (udelam vam screeny)
dik.