try {
HttpClient client = new DefaultHttpClient();
String postURL = "http://somepostaddress.com";
HttpPost post = new HttpPost(postURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("user", "kris"));
params.add(new BasicNameValuePair("pass", "xyz"));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
Log.i("RESPONSE",EntityUtils.toString(resEntity));
}
} catch (Exception e) {
e.printStackTrace();
}
this is the code that i found in http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests. afterward i will just only use the simple POST method the variable in the php, right?
example:
$user=$_POST['user']; $pass=$_POST['pass'];
however, when i execute the code, the php showed a 0 only. may i know how to solve it? thanks
p/s: sry for bad english