I am trying to send data through post method in android . But how I can receive data in server. My server is in php. I found a method in php $_post[]. how can i use it?
my client code is
client=new DefaultHttpClient();
HttpPost request=new HttpPost("http://10.0.2.2/php_server/index.php");
HttpEntity entity;
try
{
StringEntity string=new StringEntity("I am android");
entity=string;
request.setEntity(entity);
HttpResponse response=client.execute(request);
}
catch(Exception e)
{
Log.e("socket connection", e.toString());
}
It is very basic of PHP. $_POST is super-global array of PHP that stores data that was sent to a particular script using POST method.
You can use it as any other PHP array
Code below will output all the keys of $_POST and corresponding values:
If you know which key you need exactly, you can get it using
[]on array like so: