i am using web service to send user information to MySQL but PHP doesn't return posted values when i am trying to echo the values, and gives me:
Notice: Undefined index: user_name in C:\xampp\htdocs\webservice\sign_up.php on line 5
my code :
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
try {
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost("http://10.0.2.2/webservice/sign_up.php");
ArrayList<NameValuePair> post = new ArrayList<NameValuePair>(3);
post.add(new BasicNameValuePair("user_name", name));
post.add(new BasicNameValuePair("user_email", email));
post.add(new BasicNameValuePair("user_password", password));
request.setEntity(new UrlEncodedFormEntity(post));
HttpResponse response = client.execute(request);
int status = response.getStatusLine().getStatusCode();
Log.i("data posted, status = " , Integer.toString(status));
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
return null;
}
}
and PHP :
<?php
$user = $_POST["user_name"];
echo $user;
?>