Dim req As Net.HttpWebRequest
Dim resp As Net.HttpWebResponse
Dim s As IO.Stream
Dim sr As IO.StreamReader
Try
'create byte array of post data
Dim enc As New System.Text.ASCIIEncoding()
Dim postData As String = "name=bob&age=12"
Dim data As Byte() = enc.GetBytes(postData)
'create request object
'req = Net.WebRequest.Create("[URL]http://www.vbdotnetforums.com/[/URL]")
req = Net.WebRequest.Create("[URL]http://ukpc200290/test.php[/URL]")
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = data.Length
req.Method = "POST"
'get request stream to write post data too
s = req.GetRequestStream()
s.Write(data, 0, data.Length)
s.Close()
'get response
resp = req.GetResponse()
'check response data
If resp.StatusCode = Net.HttpStatusCode.OK Then
MessageBox.Show("Success")
sr = New IO.StreamReader(resp.GetResponseStream())
MessageBox.Show(sr.ReadToEnd())
End If
Catch ex As Exception
MessageBox.Show("Error Occurred")
Finally
If sr IsNot Nothing Then sr.Close()
If resp IsNot Nothing Then resp.Close()
End Try