
<?php
 
 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($_POST['tel']) && !empty($_POST['parol'])) {
      
 
require_once('connect.php');

 $tel=$_POST['tel'];
 $parol=$_POST['parol'];
 $mac=$_POST['mac'];

mysqli_set_charset($conn,"utf8");
$query = mysqli_query($conn,"SET NAMES utf8");

$query = mysqli_query($conn, "SELECT Id,agent_id, fio, boshagan, region_idlar, kontr_idlar, gruppa_idlar, brend_idlar, zakaz, tolov, otchot FROM agentlar WHERE telefon LIKE '%$tel' AND parol = '$parol'");

$response = array();
if ($query !== false && $query->num_rows > 0) {
    
while($row = mysqli_fetch_assoc($query)){
    
     $responce['Id']=$row['Id'];
     $responce['agent_id']=$row['agent_id'];
     $responce['fio']=$row['fio'];
     $responce['boshagan']=$row['boshagan'];
     $responce['region_id']=$row['region_idlar'];
     $responce['kontr_id']=$row['kontr_idlar'];
     $responce['gruppa_id']=$row['gruppa_idlar'];
     $responce['brend_id']=$row['brend_idlar'];
     $responce['zakaz']=$row['zakaz'];
     $responce['tolov']=$row['tolov'];
     $responce['otchot']=$row['otchot'];
     $responce['telefon']=$tel;
     $responce['parol']=$parol;
           
     $responce['success']=true;
     $responce['message']="Successfully";
        
        
}
}else{
   $responce['success']=false;
   $responce['message']="Берилган қийматлар бўйича базадан маълумот топилмади";  
}

    }else{
     $responce['success']=false;
     $responce['message']="Серверга жўнатилган маълумотлар тўлиқ эмас";
    
        
    }
}
else
{
    $responce['success']=false;
    $responce['message']="Error";
}
    

echo json_encode($responce);
$conn->close();
?>
