Ho provato a cambiare completamente il codice, ottengo login fallito.
codice:'controllo textbox If TextBox5.Text = Nothing Then MessageBox.Show("Please enter your username") ElseIf TextBox3.Text = Nothing Then MessageBox.Show("Please enter your password") Else Try 'Indirizzo URL Dim URL As String = "http://mysite/login.php" Dim request As HttpWebRequest = WebRequest.Create(URL) Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse) Dim reader As StreamReader = New StreamReader(response.GetResponseStream()) Dim str As String = reader.ReadLine() Dim username As String = TextBox5.Text Dim password As String = TextBox3.Text 'Scrivo i dati POST a richiesta Dim data As StringBuilder request.Method = "POST" request.ContentType = "application/x-www-form-urlencoded" Dim byteData() As Byte Dim postStream As Stream = Nothing data = New StringBuilder() 'Prendo "campo username" variabile contenuta tra virgolette data.Append(Uri.EscapeUriString("username" + TextBox5.Text.ToString)) 'Prendo il "campo password" variabile contenuta tra virgolette data.Append(Uri.EscapeUriString("password" + TextBox3.Text.ToString)) ' Creo un array di byte di dati che vogliamo inviare byteData = UTF8Encoding.UTF8.GetBytes(data.ToString()) 'Imposto la lunghezza del contenuto nelle intestazioni di richiesta request.ContentLength = byteData.Length response = request.GetResponse() 'Prendo la risposta flusso in un lettore If reader Is New StreamReader(response.GetResponseStream()) Then MessageBox.Show("login successful") End If response.Close() Catch ex As Exception MessageBox.Show("login failed") End Try End If

Rispondi quotando