它不会给出错误,但不会在数据库中插入

I have this form and script on a page:

<section class="hide-section" id="produto_1"> 
<form class="form-validate" id="feedback_form">
    <div class="campo">
        <fieldset> 
            <h1>
                <legend>
                    <center>
                        <strong>Produtos de Higiene</strong>
            </center>
        </h1><br> 
        </div>
        <fieldset class="grupo">
    <div class="campo">
            <strong><label for="Nome do Produto">Nome do Produto</label></strong> 
            <input type="text" id="DescricaoProd" name="DescricaoProd" required="" style="width:350px">
        </div>
    <div class="campo"> 
        <strong><label for="Unidade">Unidade</label></strong> 
            <input type="text" id="DescricaoUnid" name="DescricaoUnid" style="width:160px" required="" size="120">
        </div>
        </fieldset>
        <button class="btn btn-success btn_contact" type="button">Registo</button>
</form>
</section> 

<script type="text/javascript"> 
$(".btn_contact").click(function () {

                $.ajax({
                    type: "POST",
                    url: "./inserir",
                    data: $("#feedback_form").serialize(), // serializes the form's elements.
                    success: function (data)
                    {
                        if ($.trim(data) == 'true') {
                            $("#feedback_form").find('input').val(''); //clear text
                           dataType: "json",
                            $(".success_messages").removeClass('hide'); // success message
                        } else {
                            $(".error_message").removeClass('hide'); // error message
                        }
                    }
                });

            });
</script>

On the insert page I have this php code:

$name = isset($_POST["DescricaoProd"]) ? $_POST["DescricaoProd"] : '';
$unid = isset($_POST["DescricaoUnid"]) ? $_POST["DescricaoUnid"] : '';

if (!empty($name) && !empty($unid)) {  
   echo json_encode("true");
} else {
    echo json_encode("false");
}

$conn = new mysqli ("localhost", "USUARIO", "SENHA", "nome_DB");

$sql = "INSERT INTO ProdHigieneteste (DescricaoProd,DescricaoUnid) 
VALUES ('$name','$unid')";
if ($conn->query($sql)) { // check for === TRUE is not necessary
   // either put the second query in here, or just enjoy the success
} else {
   // get the error, throw a message...
}

$sql1 = "INSERT INTO StockHigieneteste (DescricaoProd,DescricaoUnid) 
VALUES ('$name','$unid')";

$query = mysqli_query($conn, "SELECT * FROM StockHigieneteste");

if ($conn->query($sql1) === TRUE) {
    //Count total number of rows
    $rowCount = $query->num_rows;
} else {
    // get the error, throw a message...
}
$conn->close();

The code was working correctly, like inserting it into the database table, but now it was checking the part of cleaning the inputs and is not already inserting into the database table, but it also does not give any errors in the console. Can anyone help identify the problem?

When I put in the beginning of the code this part:

ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);

False message appears, so it no longer changes to insert, should be true.

If you do:

var_dump ($name);
var_dump ($unid);

returns this:

string(0) "" string(0) "" "false"

Variables are not receiving value

Please use wordpress standard AJAX

add_action( 'init', 'my_script_enqueuer' );
function my_script_enqueuer() {
   wp_localize_script( 'my_voter_script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
   wp_enqueue_script( 'my_voter_script' );

}

add_action("wp_ajax_custom_function", "my_custom_function");
add_action("wp_ajax_nopriv_custom_function", "my_custom_function");

function my_custom_function()
{
    global $wpdb;

    $name = isset($_POST["DescricaoProd"]) ? $_POST["DescricaoProd"] : '';
    $unid = isset($_POST["DescricaoUnid"]) ? $_POST["DescricaoUnid"] : '';

    if (!empty($name) && !empty($unid)) {  
        echo json_encode("true");
    } else {
        echo json_encode("false");
    }

    $mydb = new wpdb('USUARIO','SENHA','nome_DB','localhost');
    $rows = $mydb->get_results("select Name from my_table");

    $mydb->insert( 
        'ProdHigieneteste', 
        array( 
            'DescricaoProd' => $name, 
            'DescricaoUnid' => $unid 
        ), 
        array( 
            '%s', 
            '%d' 
        ) 
    );

    $mydb->insert( 
        'StockHigieneteste', 
        array( 
            'DescricaoProd' => $name, 
            'DescricaoUnid' => $unid 
        ), 
        array( 
            '%s', 
            '%d' 
        ) 
    );

    /* If you want to use regular wordpress db then use $wpdb */

    $results = $wpdb->get_results("SELECT * FROM StockHigieneteste");
wp_die();
}

In ajax change URL parameter with "url : myAjax.ajaxurl,"

While putting "wp_localize_script" use your custom js slug which you have included