<?php
include('../admin/app/function/__data_app_db.php');
include_once('../admin/app/function/app_functions.php');
$__data_action = 'false';
$__go_to = '';
if(isset($_POST["name"])){

    $name = validate_jsnj_data($_POST["name"]);
    $phone = validate_jsnj_data($_POST["phone"]);
    $star = validate_jsnj_data($_POST["star"]);
    $email = validate_jsnj_data($_POST["email"]);
    $message = validate_jsnj_data($_POST["message"]);
    $_ip_jsnj = validate_jsnj_data($ip);
    $db_query = "insert into review (review_name,  review_phone, review_email, review_star, review_message, datetime, ip) values('$name','$phone','$email','$star','$message','$dateTimeForInsert', '$_ip_jsnj')";

    $res = mysqli_query($_conn_db, $db_query);

    if($res) {
        $__notif_title = 'Congratulations';
        $__notif_disc = '<div class="inner success"><p class="success">Congratulations! Your review is submitted successfully.</p></div>';
        $__notif_type = 'success';
        $__go_to = "thank-you";
        $__data_action = 'true';
    }else{
        $__notif_title = 'Oops!';
        $__notif_disc = '<div class="inner error"><p class="error">Something want wrong please reload this page.</p></div>';
        $__notif_type = 'danger';
    }

    $dataResult = array('page' => 'review', 'res' => $__data_action, 'notif_title' => $__notif_title, 'notif_desc' => $__notif_disc,  'notif_type' => $__notif_type, 'goTo' => $__go_to);
    echo json_encode($dataResult);

} else {
    echo 'Oops';
};
?>