Sends empty to PHP through post method
<p>I am working with an Android project in which I need to connect with MySQL with PHP. For that I have used PHP post method to pass data from Android to PHP. My code is given below:</p>

<pre><code>HttpURLConnection httpURLConnection= (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream=httpURLConnection.getOutputStream();

BufferedWriter bufferedWriter=new BufferedWriter(new OutputStreamWriter(outputStream,"UTF-8"));
String post_data=URLEncoder.encode("mobile","UTF-8")+"="+URLEncoder.encode(mobile,"UTF-8")+"&amp;"+
URLEncoder.encode("password","UTF-8")+"="+URLEncoder.encode(password,"UTF-8");
bufferedWriter.write(post_data);
// Toast.makeText(context,"after data pass",Toast.LENGTH_LONG).show();
bufferedWriter.flush();
bufferedWriter.close();

InputStream inputStream=httpURLConnection.getInputStream();
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
String result="";
String line="";
while((line=bufferedReader.readLine())!=null){
    result += line;
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return  result;
</code></pre>

<p>But the problem is in the PHP script. No data is passes, rather the PHP  script receives an empty string. Why this occurs? And what should be the solution for that?
My PHP code is:</p>

<pre><code>&lt;?php 
require "conn1.php"; 
$mobile= $_POST["mobile"]; 
$user_password= $_POST["password"]; 
$query="select * from pharmacytable where mobile like '$mobile' and PharPassword like '$user_password';"; 
$result=mysqli_query($conn, $query); 
if(mysqli_num_rows($result)&gt;0){ 
    echo "Login success"; 
} else{ 
    echo "Login failed"; 
} 
?&gt;
</code></pre>