<?php

// Created by Abdullayev Olloyor  on 10.02.2020

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // if (!empty($_POST['user_id']) && !empty($_POST['sorov_turi']) && !empty($_POST['sorov_izox']) ) {
    if (isset($_POST['user_id']) && isset($_POST['sorov_turi']) && isset($_POST['sorov_izox']) ) {

        require_once('connect.php');

        $user_id = $_POST['user_id'];
        $sorov_turi = $_POST['sorov_turi'];
        $sorov_izox = $_POST['sorov_izox'];

        $sorov_izox = str_replace('<br />', ' ', $sorov_izox);

        mysqli_set_charset($conn,"utf8");

        $mysql_qry = "INSERT INTO savollar (user_id,sorov_turi,sorov_izox) VALUES ('$user_id','$sorov_turi','$sorov_izox')";

        if($conn->query($mysql_qry) == TRUE){
            $last_id = $conn->insert_id;
            echo "" . $last_id;

        } else {
            echo 'no_c';
        }
        $conn->close();
    }else{
        echo 'no_enough_info';
    }
}

?>
