0
// xamarin.android c# code 
void mButtonCreateContact_Click(object sender, EventArgs e)
{
    WebClient client = new WebClient();
    Uri uri = new Uri("http://www.mydomainname.com/abcd.php");
    NameValueCollection parameters = new NameValueCollection();
    parameters.Add("Name", txtName.Text);
    parameters.Add("Number", txtNumber.Text);`
    client.UploadValuesCompleted += client_UploadValuesCompleted;
    client.UploadValuesAsync(uri, parameters);          
}

Here I am passing two parameters ater getting input from the user. However in the PHP code it always returns false in the isset['Name'] function and goes into the else statement

if (isset($_POST['Name']) && isset($_POST['Number']))
{
    $mName = $_POST['Name'];
    $mNumber = $_POST['Number'];
    echo 'true';
}
else
{
    echo 'false';
}
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Mudassir Dehghani
  • 111
  • 1
  • 1
  • 4
  • Try using `$_GET` instead of `$_POST` to get the values, if you want to POST instead, try this : http://stackoverflow.com/a/5401597/1870760 – Hatted Rooster Sep 18 '15 at 12:24

4 Answers4

1

You need to set request paramater POST in WebClient.

1

You're currently sending a GET with the values, if you want to use POST instead, call it like this:

void mButtonCreateContact_Click(object sender, EventArgs e)
    {
        WebClient client = new WebClient();
        Uri uri = new Uri("http://www.mydomainname.com/abcd.php");
        NameValueCollection parameters = new NameValueCollection();
        parameters.Add("Name", txtName.Text);
        parameters.Add("Number", txtNumber.Text);
        client.UploadValuesCompleted += client_UploadValuesCompleted;
        client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        client.UploadValuesAsync(uri, "POST", parameters);          
    }
Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
0

USE to check with POST

client.UploadValuesAsync(uri, "POST", parameters);
Gaurang Joshi
  • 684
  • 16
  • 32
-1

Best way is user $_REQUEST. WHATEVER YOU USE post or get.