如何在PHP android中1条件为真时从服务器获取数据?

I am making PHP file where if the email is matched with email given in database, then it should show correct password.

I am new to PHP so don't know much about it.

Here is my php code:

<?php 

include ('config.php');

$sql = "SELECT * FROM UserInfo WHERE email='".$email."'";



$r = mysqli_query($con,$sql);

$result = array();

while($row = mysqli_fetch_array($r)){

    array_push($result,array('password'=>$row['password'],));
}

echo json_encode(array('result'=>$result));

mysqli_close($con);

?>

I am getting this answer if I checked with browser {"result":[]}

use below code you will get all result

$m = mysqli_query($con,"SELECT * FROM `UserInfo` WHERE `email`='".$email."'");
         while($result=mysqli_fetch_assoc($m))
            {
             $flag[]=$result;
            } 
         print(json_encode($flag));

step 1 connection with database make new db_connect.php file

do needful changes change 'Host','USER','PASS','DB'

<?php
 define('HOST','localhost');
 define('USER','root');
 define('PASS','Root@123');
 define('DB','your database name');

 $con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
 ?>

check connection using below URL do needful changes

http://192.168.1.85/AskUsCash/db_connect.php

http://ip address/folder name/db_connect.php

Make php file test.php

check table name and column name are same as in query if not then change it from php file. make sure your table name is UserInfo and column name is email

<?php
    include 'db_connect.php';
    $request=$_REQUEST['getdata'];

     // customer Registration form
    if($request=="checkEmail")
        {
             $Email =$_REQUEST['insert_Email'];  
             $m = mysqli_query($con,"SELECT * FROM `UserInfo` WHERE `email`='".$Email."'");
             while($result=mysqli_fetch_assoc($m))
                {
                 $flag[]=$result;
                } 
             print(json_encode($flag));

        }
    else
    {

        $flag['Error']='2';
        print(json_encode($flag));      

    }       
    ?>

check result do needful changes below is my url

   http://192.168.1.85/AskUsCash/db_connect.php
192.168.1.85/AskUsCash/test.php/?getdata=checkEmail&insert_Email=borhadyog@gmail.com

change with your credential.

http://192.168.1.85/AskUsCash/db_connect.php

and pass parameter from

?getdata=checkEmail&insert_Email=borhadyog@gmail.com 

valid email which is in database change email address