I am sending data from my Android app to php but php is not getting any data. I have doubt that I am missing something in my php code. To connect php and Android, is only php URL is needed in android code or something else I have to do? I have stunk into this problem. Any help would be appreciated. My full php code is:
<?php
$user_email=$_POST['email'];
echo "Email is $user_email";
?>
My Android code is:
URL server_url = new URL("http://www.myURL.com/Jobs/login.php");
HttpURLConnection urlc = (HttpURLConnection) server_url.openConnection();
//header stuff
urlc.setRequestMethod("POST");
urlc.setRequestProperty("Content-Language", "en-US");
urlc.setRequestProperty("Accept-Encoding", "identity");
//params
String urlParameters = "email="+mEmail;
//send post
urlc.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(urlc.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
//read result
BufferedReader in = new BufferedReader(
new InputStreamReader(urlc.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString()
);
Your PHP code doesn't have issue for Optimized code with email filter, if email address there.
Kindly replace your old code.
You need to check your Android code to see if the field email is properly configured or not.
I'm 100% sure there is no issue with the PHP Code.