如何用POST方法打开php?

时间:2017-03-11 18:16:03

标签: php vb.net

如何打开/重定向到我的PHP(URL),下面是我的代码。感谢。

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

    Dim postData As String = "submit=submit&amountPrice=1.50"
    Dim request As WebRequest = WebRequest.Create("http://localhost/payment/process.php")
    request.Method = "POST"
    Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
    request.ContentType = "application/x-www-form-urlencoded"
    request.ContentLength = byteArray.Length
    Dim dataStream As Stream = request.GetRequestStream()
    dataStream.Write(byteArray, 0, byteArray.Length)
    dataStream.Close()
    Dim response As WebResponse = request.GetResponse()
    dataStream = response.GetResponseStream()
    Dim reader As New StreamReader(dataStream)
    Dim responseFromServer As String = reader.ReadToEnd()
    reader.Close()
    dataStream.Close()
    response.Close()
    MsgBox(responseFromServer)

End Sub

以上代码用于向我的PHP发送POST并在MsgBox中读取响应,但我无法打开URL。我怎么能这样做?

0 个答案:

没有答案