Note that there are some explanatory texts on larger screens.

plurals
  1. POSend POST values and get response using HttpWebRequest
    primarykey
    data
    text
    <p>I have this php file:</p> <pre><code>&lt;?php if (isset($_POST['message'])) { $msg = $_POST['message']; if($msg == "age") echo "I am 18"; else if($msg == "name") echo "my name is Jonathan"; else echo "I do not know"; } ?&gt; </code></pre> <p>I want to make a HttpWebRequest in VB.NET such that if I send the value "age" from a TextBox: <img src="https://i.stack.imgur.com/SQQog.png" alt="enter image description here"> <br> To get this following msgbox: <br> <img src="https://i.stack.imgur.com/yFz1p.png" alt="enter image description here"> <br> <br> I tried something like this : <br></p> <pre><code>Public Sub SendPostData(ByVal site As String, ByVal message As String) Dim request As WebRequest request = WebRequest.Create(site) Dim response As WebResponse Dim postData As String = "message=" + message Dim data As Byte() = Encoding.UTF8.GetBytes(postData) request.Method = "POST" request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = data.Length Dim stream As Stream = request.GetRequestStream() stream.Write(data, 0, data.Length) stream.Close() response = request.GetResponse() Dim sr As New StreamReader(response.GetResponseStream()) MsgBox(sr.ReadToEnd) End Sub </code></pre> <p><strong><br> and I got this :</strong> <br> <img src="https://i.stack.imgur.com/sETy5.png" alt="enter image description here"></p> <p><br> Any idea why i'm getting that instead of one of the 3 possible message in the php file? ("I am 18", "my name is Jonathan", or "I do not know") ? Please note that I tested the php normally from a html form and it worked, so I wonder why it's not working from the program.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload