I want to post variables from C# to a php-script on my webserver. I tried this following code from the internet but it returns this error message: Error: The remote server returned an error. (406) Not Acceptable.
The c# part:
string URI = "https://myserver.com/post.php";
string myParameters = "param1=value1¶m2=value2";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string HtmlResult = wc.UploadString(URI, myParameters);
MessageBox.Show(HtmlResult);
}
The php part:
<?php
if(isset($_POST['param1']) && isset($_POST['param2']))
{
$user = $_POST['param1'];
$date = $_POST['param2'];
echo $user . ' : ' . $date;
}
?>
I have tested it with a test post server and it works but it won't work on my server.