 |
|
รบกวนผู้รูป ช่วยดูโค้ด ไห้ทีครับ มันเป็นโค้ด Login ผ่านเว็บหรือยังไงหรอครับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
Try
Dim myWebClient As New WebClient()
Dim myURL As String = String.Format("http://crazy-pro.tk/bbs/forum.php", txtuser.Text, txtpassword.Text)
Dim web_response As Stream = myWebClient.OpenRead(myURL)
Dim stream_reader As New StreamReader(web_response)
Dim myDATA As String = stream_reader.ReadToEnd
If myDATA.Contains("Username") Then
MsgBox("Wrong username or password!", MsgBoxStyle.Information)
Form2.Show()
Exit Sub
Else
MsgBox("Error " & myDATA, MsgBoxStyle.Information)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub CheckLogout()
Try
Dim myWebClient As New WebClient()
Dim myURL As String = String.Format("http://crazy-pro.tk/bbs/forum.php")
Dim web_response As Stream = myWebClient.OpenRead(myURL)
Dim stream_reader As New StreamReader(web_response)
Dim myDATA As String = stream_reader.ReadToEnd
If myDATA.Contains("LOGOUT") Then
MsgBox("Logout!", MsgBoxStyle.Information)
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
'CheckLogin()
Dim myURL As String = String.Format("http://crazy-pro.tk/bbs/forum.php", txtuser.Text, txtpassword.Text)
End Sub
Private Sub btnlogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogout.Click
'CheckLogout()
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
MsgBox("Wrong username or password!", MsgBoxStyle.Information)
Form2.Show()
Exit Sub
'MsgBox("Error " & myDATA, MsgBoxStyle.Information)
End Sub
End Class
ครับ
มันควน ทำยังไง คือผมจะทำLogin ผ่าน ฐานข้อมูลเว็บไซต์อะครับ หรือใครมี ข้อมูลดีๆผมขอหน่อยได้ปะครับ55
Tag : .NET, VB.NET
|
|
 |
 |
 |
 |
Date :
2012-09-17 19:34:50 |
By :
Aunz |
View :
1183 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวอย่างนี้เลยครับ เป็น Sliverlight แต่ใช้ .NET เช่นเดียวกันครับ
Code (VB.NET)
Private Sub btnLogin_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
Dim url As String = "http://localhost/myphp/checkLogin.php"
Dim uri As Uri = New Uri(url, UriKind.Absolute)
Dim postData As StringBuilder = New StringBuilder()
postData.AppendFormat("{0}={1}", "sUsername", HttpUtility.UrlEncode(Me.txtUsername.Text))
postData.AppendFormat("&{0}={1}", "sPassword", HttpUtility.UrlEncode(Me.txtPassword.Password.ToString))
Dim client As WebClient
client = New WebClient()
client.Headers(HttpRequestHeader.ContentType) = "application/x-www-form-urlencoded"
client.Headers(HttpRequestHeader.ContentLength) = postData.Length.ToString()
AddHandler client.UploadStringCompleted, AddressOf client_UploadStringCompleted
AddHandler client.UploadProgressChanged, AddressOf client_UploadProgressChanged
client.UploadStringAsync(uri, "POST", postData.ToString())
prog = New ProgressIndicator()
prog.IsIndeterminate = True
prog.IsVisible = True
prog.Text = "Loading...."
SystemTray.SetProgressIndicator(Me, prog)
End Sub
Private Sub client_UploadProgressChanged(sender As Object, e As UploadProgressChangedEventArgs)
'Me.txtResult.Text = "Uploading.... " & e.ProgressPercentage & "%"
End Sub
Private Sub client_UploadStringCompleted(sender As Object, e As UploadStringCompletedEventArgs)
If e.Cancelled = False And e.Error Is Nothing Then
prog.IsVisible = False
Dim result As String() = e.Result.ToString.Split("|")
Dim strStatus As String = result(0).ToString()
Dim strMemberID As String = result(1).ToString()
Dim strError As String = result(2).ToString()
If strStatus = "0" Then
MessageBox.Show(strError)
Else
NavigationService.Navigate(New Uri("/DetailPage.xaml?sMemberID=" & strMemberID, UriKind.Relative))
End If
End If
End Sub
Go to : Windows Phone Login Username and Password (PHP and MySQL Web Server)
|
 |
 |
 |
 |
Date :
2012-09-18 11:35:16 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยแนะนำขั้นตอนไห้ได้ปะครับ
|
 |
 |
 |
 |
Date :
2012-09-18 18:53:46 |
By :
warakay |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณไม่ได้อ่านเหรอครับ
|
 |
 |
 |
 |
Date :
2012-09-18 20:18:52 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|