<?php
// $nameSurname1 = $_POST["nameSurname1"];
// $nameSurname2 = $_POST["nameSurname2"];
// echo "$nameSurname1, $nameSurname2";
$browser = $_POST["browser"];
$nameSurname1 = filter_var(trim($_POST['nameSurname1']), FILTER_SANITIZE_STRING);
$nameSurname2 = filter_var(trim($_POST['nameSurname2']), FILTER_SANITIZE_STRING);
$email1 = filter_var(trim($_POST['email1']), FILTER_SANITIZE_STRING);
$email2 = filter_var(trim($_POST['email2']), FILTER_SANITIZE_STRING);
$beverages1 = $_POST['beverages1'];
$item1 = implode(", ", $beverages1);
$dishes1 = $_POST['dishes1'];
$eat1 = implode(", ", $dishes1);
$mysql = new mysqli("d125440.hostru09.fornex.host", "d125440", "*******", "d125440_ae");
if ($browser == "приду") {
$mysql->query("INSERT INTO `users` (`name`,`email`, `browser`, `beverages`, `dishes`) VALUES('$nameSurname1', '$email1', '$browser', '$item1', '$eat1')");
} elseif ($browser == "мы придем"){
$beverages2 = $_POST['beverages2'];
$item2 = implode(", ", $beverages2);
$dishes2 = $_POST['dishes2'];
$eat2 = implode(", ", $dishes2);
$mysql->query("INSERT INTO `users` (`name`,`email`, `browser`, `beverages`, `dishes`) VALUES('$nameSurname1', '$email1', '$browser', '$item1', '$eat1')");
$mysql->query("INSERT INTO `users` (`name`,`email`, `browser`, `beverages`, `dishes`) VALUES('$nameSurname2', '$email2', '$browser', '$item2', '$eat2')");
} else {
$mysql->query("INSERT INTO `users` (`name`,`email`, `browser`, `beverages`, `dishes`) VALUES('$nameSurname', '$email1', '$browser', '$item1', '$eat1')");
}
header("Location: /");
?>