<?php
//basic include files
require_once('../../db.php');

$hotelid      = mysqli_escape_string($conn, $_POST['hotelid']);
$hotelname    = mysqli_escape_string($conn, $_POST['hotelname']);
$city_id      = mysqli_escape_string($conn, $_POST['city']);
$ota_priority = mysqli_escape_string($conn, $_POST['ota_priority']);
$element_id   = mysqli_escape_string($conn, $_POST['element_id']);
$longitud     = mysqli_escape_string($conn, $_POST['longitud']);
$latitud      = mysqli_escape_string($conn, $_POST['latitud']);
$guests       = mysqli_escape_string($conn, $_POST['guests']);
$maxguests    = mysqli_escape_string($conn, $_POST['maxguests']);
$checkin      = mysqli_escape_string($conn, $_POST['checkin']);
$checkout     = mysqli_escape_string($conn, $_POST['checkout']);
$rooms        = mysqli_escape_string($conn, $_POST['rooms']);

//Search Data
$checkin       = mysqli_escape_string($conn, $_POST['checkin']);
$checkout      = mysqli_escape_string($conn, $_POST['checkout']);
$rooms         = mysqli_escape_string($conn, $_POST['rooms']);
//room 1
$adults0       = mysqli_escape_string($conn, $_POST['adults']);
$children0     = mysqli_escape_string($conn, $_POST['children']);
$children0age0 = mysqli_escape_string($conn, $_POST['age']);
$children0age1 = mysqli_escape_string($conn, $_POST['age2']);
$children0age2 = mysqli_escape_string($conn, $_POST['age3']);
//room 2
$adults1       = mysqli_escape_string($conn, $_POST['adults2']);
$children1     = mysqli_escape_string($conn, $_POST['children2']);
$children1age0 = mysqli_escape_string($conn, $_POST['age2_1']);
$children1age1 = mysqli_escape_string($conn, $_POST['age2_2']);
$children1age2 = mysqli_escape_string($conn, $_POST['age2_3']);
//room 3
$adults2       = mysqli_escape_string($conn, $_POST['adults3']);
$children2     = mysqli_escape_string($conn, $_POST['children3']);
$children2age0 = mysqli_escape_string($conn, $_POST['age3_1']);
$children2age1 = mysqli_escape_string($conn, $_POST['age3_2']);
$children2age2 = mysqli_escape_string($conn, $_POST['age3_3']);
//room 4
$adults3       = mysqli_escape_string($conn, $_POST['adults4']);
$children3     = mysqli_escape_string($conn, $_POST['children4']);
$children3age0 = mysqli_escape_string($conn, $_POST['age4_1']);
$children3age1 = mysqli_escape_string($conn, $_POST['age4_2']);
$children3age2 = mysqli_escape_string($conn, $_POST['age4_3']);

//Comments
$quality  = mysqli_escape_string($conn, $_POST['quality']);
$nickname = mysqli_escape_string($conn, $_POST['nickname']);
$review   = mysqli_escape_string($conn, $_POST['review']);
$text     = mysqli_escape_string($conn, $_POST['text']);

if (!empty($_POST)) {
    if (empty($text)) {
        mysqli_query($conn, "INSERT INTO reviews (hotelid,quality,nickname,review,date_review) VALUES('$hotelid','$quality','$nickname','$review',now())");
    }
}

header("Location: ../../hotel.php?hotelid=" . $hotelid . "&hotelname=" . $hotelname . "&city=" . $city_id . "&element_id=&ota_priority=" . $ota_priority . "&longitud=" . $longitud . "&latitud=" . $latitud . "&guests=" . $guests . "&maxguests=" . $maxguests . "&checkin=" . $checkin . "&checkout=" . $checkout . "&rooms=" . $rooms . "&adults=" . $adults0 . "&children=" . $children0 . "&age=" . $children0age0 . "&age2=" . $children0age1 . "&age3=" . $children0age2 . "&adults2=" . $adults1 . "&children2=" . $children1 . "&age2_1=" . $children1age0 . "&age2_2=" . $children1age1 . "&age2_3=" . $children1age2 . "&adults3=" . $adults2 . "&children3=" . $children2 . "&age3_1=" . $children2age0 . "&age3_2=" . $children2age1 . "&age3_3=" . $children2age2 . "&adults4=" . $adults3 . "&children4=" . $children3 . "&age4_1=" . $children3age0 . "&age4_2=" . $children3age1 . "&age4_3=" . $children3age2);
?>