Code:
private async Task httpAsync()
{
var data = new StringContent("1254", Encoding.UTF8, "application/x-www-form-urlencoded");
var url = "https://mywebsite.com/insert.php";
using var client = new HttpClient();
var response = await client.PostAsync(url, data);
string result = response.Content.ReadAsStringAsync().Result;
textBox2.Text = result;
}
private async void button3_AsyncClick(object sender, EventArgs e)
{
await httpAsync();
}
My insert.php script:
<?php
$postdata = $_GET['data'];
echo $postdata;
?>
The Error I get: Notice: Undefined index: data in /storage/ssd3/643/15098643/public_html/insert.php
I am still new to this can someone assist me with this error. I am trying to echo back the "1254" sent to the server, for testing.