$query1 = "select * empresas where nombre = '{$company}';"; $result1 = pg_query($GLOBALS["conn"], $query1); $rowE = pg_fetch_row($result1); $GLOBALS['rowEmpresa'] = $rowE; } $p = $GLOBALS["rowUser"][0]; $e = $GLOBALS['rowEmpresa'][0]; $query2 = "insert into persona_empresa(idPersona, idEmpresa) values({$p},{$e});"; $result2 = pg_query($GLOBALS["conn"], $query2); return array('state' => "Correcto", 'box' => "#box-company-profile"); } else { $GLOBALS["estado"] = 1; return array('state' => "Incorrecto", 'box' => "#box-company-profile", 'errorBox' => "#error-company-profile", 'error' => "Debe tener al menos 2 caracteres."); } } $array_data[] = nameValidate($name); $array_data[] = lastNameValidate($lastName); $array_data[] = emailValidate($email, $username); $query2 = "delete from persona_empresa where idPersona={$rowUser['0']}"; $result2 = pg_query($GLOBALS["conn"], $query2); unset($_SESSION["rowCompany"]); if ($companyName != "") { $array_data[] = companyNameValidate($companyName); $query = "Select * from empresas where nombre='{$companyName}'"; $result = pg_query($conn, $query); $row = pg_fetch_row($result); $_SESSION["rowCompany"] = $row; } if ($estado === 0) { $query = "update personas set nombre='{$name}', apellidos='{$lastName}', correo='{$email}' where idPersona='{$rowUser['0']}'"; $result = pg_query($conn, $query);
$orderCost += $totalPrice; } return $orderCost; } if (empty($_POST) && isset($_COOKIE['products']) && !empty($_COOKIE['products'])) { $orderCost = orderCost($connection); echo "<div class=order-cost> Общая стоимость заказа: <span>{$orderCost}</span> рублей</div>"; include_once "templates/_create-order-form.php"; } elseif (empty($_COOKIE['products'])) { echo "Ваша корзина пуста"; } if (!empty($_POST) && isset($_COOKIE['products']) && !empty($_COOKIE['products'])) { include_once "order_data-validate.php"; // Data sanitising and validation $errors = []; $name = nameValidate($errors, $_POST['name']); $address = addressValidate($errors, $_POST['address']); $email = emailValidate($errors, $_POST['email']); $addition = ""; if (v::string()->notEmpty()->validate(filter_var(trim($_POST['addition']), FILTER_SANITIZE_STRING))) { $addition = filter_var(trim($_POST['addition']), FILTER_SANITIZE_STRING); } if (!v::arr()->notEmpty()->validate($errors)) { // No errors after form validation $order = new \App\DB\OrdersProducts($connection, $name, $address, $email, $addition); foreach ($_COOKIE['products'] as $id => $value) { setcookie("products[{$id}]", "", time() - 3600, "/"); } echo "<p class='order-created'>Поздравляем! Заказ оформлен</p>"; echo "<a href=" . \App\Utilities\Options::URL . "../catalog class='adm-btn order'>В каталог</a>"; header('Refresh:0 url=/');