<?php
$arr= array();
$mobile= $_POST['mobile'];
$password= $_POST['password'];
include("connect_db.php");
$sql_login= "SELECT * FROM registers WHERE mobile='$mobile' and password='$password'";
$res= mysqli_query($con,$sql_login);
if($res){
    if(mysqli_num_rows($res)>0){
        $data['status']= "success";
        array_push($arr,$data);
        $rows= mysqli_fetch_row($res);
        if($rows[4]=='active'){
            $data['id']=$rows[0];
            $data['name']=$rows[1];
            $data['mobile']=$rows[2];
            $data['password']=$rows[3];
            $data['status']=$rows[4];
            $data['created_at']=$rows[5];
            $data['updated_at']=$rows[6];
            array_push($arr,$data);
        }
        else{
            $data['status']="fail";
            $data['message']="User has been deactivated";
            array_push($arr,$data);
        }
    }
    else{
        $data['status']="fail";
        $data['message']="Invalid username or password";
        array_push($arr,$data);
    }
}
else{
    $data['status']="fail";
    $data['message']=mysqli_error($con);
    array_push($arr,$data);
}
echo json_encode($arr);
?>