<?php

// Created by Ibrohimjon Ahmadjonov Ilhomjon o'g'li on 07.02.2020
header('Content-type: text/html; charset=UTF-8');
require "connect.php";


$umum_soni = 0;

$tel = $_POST['tel'];
$parol = $_POST['parol'];
$count=1;

$sql_sorov = "SELECT dostavshik_id, agent_id, fio, telefon, parol, boshagan FROM dostavshik WHERE telefon LIKE '%$tel' AND parol = '$parol' AND boshagan = '0'";

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

if ($javob !== false && $javob->num_rows > 0) {
  
    while($row=mysqli_fetch_array($javob)){

        $dostavshik_id=$row['dostavshik_id'];
        $agent_id=$row['agent_id'];
        $fio=$row['fio'];
    	$fio=str_replace('"', '|', $fio);
		$telefon=$row['telefon'];
		$parol=$row['parol'];
        $boshagan=$row['boshagan'];

       // echo ''.$dostavshik_id.'^'.$agent_id.'^'.$fio.'^'.$telefon.'^'.$parol.'~';

            $responce['dostavshik_id']=$dostavshik_id;
            $responce['agent_id']=$agent_id;
            $responce['fio']=$fio;
            $responce['telefon']=$telefon;
            $responce['parol']=$parol;
            $responce['boshagan']=$boshagan;

			$count++;

      		echo json_encode($responce);

    	$conn->close();
    	return;
    }
}
if($count == 1){

	echo "no_c";
	$conn->close();
	return;
} else{

	echo "no_";
	$conn->close();
	return;
}


$conn->close();
?>
