<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    if (!empty($_POST['agent_id']) && !empty($_POST['tolov_txt']))
    {

        require_once ('connect.php');

        $agent_id = $_POST['agent_id'];
        $region_id = $_POST['region_id'];
        $tolov_txt = $_POST['tolov_txt'];


        date_default_timezone_set('Asia/Tashkent');
        $timestamp = time();
        $date_time = date("H:i:s d.m.Y", $timestamp);

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

        $query = "INSERT INTO tolovlar (agent_id, region_id, tolov_txt, vaqti) VALUES ('$agent_id','$region_id','$tolov_txt','$date_time')";

        if (mysqli_query($conn, $query))
        {
            echo "ok1";
        }
        else
        {
            echo "no";
        }
    }
    else
    {
        echo "no_c";
    }
    $conn->close();
}
else
{
    echo "error";
}
?>
