title: Login registration with php mysql api in xamarin
body: <p>Iam developing an android app that contain login system using mysql webservices
  When run the app on device the SignUp button does not work and nothing happens, also on click signIn button I get handle exception and connection refused error
      what is wrong in code.
      I want to connect my app with mysql database using web services any solution for me</p>
  
  <p>this is my SignUp activity in xamarin</p>
  
  <pre><code>    [Activity(Label = "SignUp")]
      public class SignUp : Activity, View.IOnClickListener
      {
          EditText userName, userEmail, userPassword;
          Button signUp;
  
  
          protected override void OnCreate(Bundle savedInstanceState)
          {
              base.OnCreate(savedInstanceState);
  
              // Create your application here
              SetContentView(Resource.Layout.sign_up);
              initialize();
          }
          public void initialize()
          {
              userName = (EditText)FindViewById(Resource.Id.newUserName);
              userEmail = (EditText)FindViewById(Resource.Id.newUserEmail);
              userPassword = (EditText)FindViewById(Resource.Id.newUserPassword);
              signUp = (Button)FindViewById(Resource.Id.signUpBtn);
              signUp.SetOnClickListener(this);
          }
  
          public void OnClick(View v)
          {
              switch (v.Id)
              {
                  case Resource.Id.signUpBtn:
                      if (userName.Text.Equals("") &amp;&amp; userEmail.Text.Equals("") &amp;&amp; userPassword.Text.Equals(""))
                      {
                          Toast.MakeText(this, "Empty Fields Found", ToastLength.Short).Show();
                      }
                      else {
  
                          signUpAsync s = new signUpAsync(this);
                          s.Execute();
                      }
                      break;
              }
          }
  
          public class signUpAsync : AsyncTask&lt;Java.Lang.Object, Java.Lang.Object, Java.Lang.Object&gt;
          {
  
              SignUp signObj;
  
              public signUpAsync(SignUp signObj)
              {
                  this.signObj = signObj;
              }
              string fullname,email,password;
  
              protected override void OnPreExecute()
              {
                  base.OnPreExecute();
                  fullname = signObj.userName.Text;
                  email = signObj.userEmail.Text;
                  password = signObj.userPassword.Text;
              }
  
              protected override Java.Lang.Object RunInBackground(params Java.Lang.Object[] @params)
              {
                  WebClient client = new WebClient();
                  Uri uri = new Uri("http://localhost/test/xamarinsignUp.php");
                  NameValueCollection parameters = new NameValueCollection();
                  parameters.Add("fullname", fullname);
                  parameters.Add("email", email);
                  parameters.Add("password", password);
                  client.UploadValuesAsync(uri, parameters);
  
                  return null;
              }
  
          }
  
      }
  }
  
  this is Sign in activity in xamarin
  
      [Activity(Label = "XamarinLogin", MainLauncher = true, Icon = "@mipmap/icon")]
      public class MainActivity : Activity, Android.Views.View.IOnClickListener
      {
  
          TextView signUp;
          EditText email, password;
          Button signIn;
          signInAsync sn;
  
          protected override void OnCreate(Bundle savedInstanceState)
          {
              base.OnCreate(savedInstanceState);
  
              // Set our view from the "main" layout resource
              SetContentView(Resource.Layout.Main);
              initialize();
          }
          public void initialize()
          {
              signUp = (TextView)FindViewById(Resource.Id.signUpTxt);
              email = (EditText)FindViewById(Resource.Id.userEmail);
              password = (EditText)FindViewById(Resource.Id.userPass);
              signIn = (Button)FindViewById(Resource.Id.signInBtn);
              signUp.SetOnClickListener(this);
              signIn.SetOnClickListener(this);
          }
  
          public void OnClick(View v)
          {
              switch (v.Id)
              {
                  case Resource.Id.signInBtn:
                      sn = new signInAsync(this);
                      sn.Execute();
                      break;
                  case Resource.Id.signUpTxt:
                      Intent up = new Intent(this, typeof(SignUp));
                      StartActivity(up);
                      Finish();
                      break;
              }
          }
  
          public class signInAsync : AsyncTask&lt;Java.Lang.Object, Java.Lang.Object, Java.Lang.Object&gt;
          {
              MainActivity mainActivity;
  
              public signInAsync(MainActivity mainActivity)
              {
                  this.mainActivity = mainActivity;
              }
              string userEmail, userPassword;
              protected override void OnPreExecute()
              {
                  base.OnPreExecute();
  
                  userEmail = mainActivity.email.Text;
                  userPassword = mainActivity.password.Text;
              }
              protected override Java.Lang.Object RunInBackground(params Java.Lang.Object[] @params)
              {
  
                  WebClient client = new WebClient();
                  Uri uri = new Uri("http://localhost/test/xamarinsignIn.php");
                  NameValueCollection parameters = new NameValueCollection();
                  parameters.Add("email", userEmail);
                  parameters.Add("password", userPassword);
                  var response = client.UploadValues(uri, parameters);
                  var responseString = Encoding.Default.GetString(response);
                  JSONObject ob = new JSONObject(responseString);
                  if (ob.OptString("success").Equals("1"))
                  {
                      mainActivity.RunOnUiThread(() =&gt;
                      Toast.MakeText(mainActivity, "You Successfully LogIn", ToastLength.Short).Show());
                  }
                  else {
                      mainActivity.RunOnUiThread(() =&gt;
                                                 Toast.MakeText(mainActivity, "InValid Email or Password", ToastLength.Short).Show());
  
                  }
  
                  return null;
              }
          }
  
      }
  }
  
  My Signin.Php file upload to wamp server
  
  &lt;?php
      mysql_connect("localhost","root","");
      mysql_select_db("citysoft_codec");
  if(isset($_POST['email']) &amp;&amp; isset($_POST['password'])){
          $SignInEmail  = $_POST['email'];
          $SignInPass = $_POST['password'];
  
          $user_query = mysql_query("select * from user where email='$SignInEmail' AND password='$SignInPass'");
  
          if(mysql_fetch_row($user_query)){
              $response["success"]=1;
              echo json_encode($response);
          }
          else{
              $response["error"]=2;
              echo json_encode($response);
          }
  }
  else{
      $response["error"]=3;
      echo json_encode($response);
  }
  </code></pre>
  
  <hr>
  
  <pre><code>My signup.php file upload to wamp server
  
  &lt;?php
  
      header('Content-type: application/json');
      mysql_connect("localhost","root","");
      mysql_select_db("citysoft_codec");
          $name = $_POST['fullname'];
          $email = $_POST['email'];
          $pass = $_POST['password'];
  
          $query = mysql_query("insert into user VALUES(DEFAULT,'$name','$email','$pass')");
          if($query){
              $response["success"]=1;
              echo json_encode($response);
          }
          else{
              $response["error"]=2;
              echo json_encode($response);
          }
  </code></pre>