<?php

 $responce = array();
 $responce2 = array();
 if ($_SERVER['REQUEST_METHOD'] == 'POST') {


    require_once('connect.php');

    $_POST = json_decode(file_get_contents("php://input"),true);
    $login=$_POST['login'];
    $parol=$_POST['parol'];

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

    $query = mysqli_query($conn, "SELECT user_id, fio FROM users WHERE telefon = '$login' AND parol = '$parol'");

    if ($query !== false && $query->num_rows > 0) {

        $agent_id="";
        while($row = mysqli_fetch_assoc($query)){

            $agent_id=$row['agent_id'];

            $responce2['Id']=$row['user_id'];
            $responce2['name']=$row['fio'];

        }

        $responce[] = $responce2;
    }
}

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