if(empty($errors)){
$sql = "INSERT INTO `comments` (`name`, `surname`, `message`) VALUES(:name, :surname, :message)";
$query = $conn->prepare($sql);
$query->execute(['name' => $name, 'surname' => $surname, 'message' => $message]);
header('location: /');
}else{
header('location: /index.php?error='.array_shift($errors).' ');
}
<div class="comments__errors">
<?php
if(isset($_GET['error'])){
echo $_GET['error'];
}
?>
</div>
<?php
require 'config.php';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$name = $_POST['name'];
$surname = $_POST['surname'];
$message = $_POST['message'];
$errors = [];
if($name == '' || $surname == '' || $message == ''){
$errors[] = 'Не все поля заполнены!';
}else if(!preg_match('/[a-z]/', $name || !preg_match('/[a-z]/', $surname) || !preg_match('/[a-z]/', $message))){
$errors[] = 'В полях должны содержатся буквы!';
}
if(empty($errors)){
$sql = "INSERT INTO `comments` (`name`, `surname`, `message`) VALUES(:name, :surname, :message)";
$query = $conn->prepare($sql);
$query->execute(['name' => $name, 'surname' => $surname, 'message' => $message]);
}else{
header('location: /');
}
}
?>
const line = document.querySelector('.order-button__line--bottom');
const lineBottom = getComputedStyle(line).bottom;
console.log(lineBottom); /*Выводит -144px*/
const button = document.querySelector('.order-button');
const buttonHeight = button.offsetHeight;
console.log(buttonHeight); /*Выводит 144*/
var percent = buttonHeight / lineBottom * 100;
console.log(percent); /*Выводит Nan*/
console.log(getComputedStyle(element).bottom); /*Выводит в консоль bottom в пикселях*/
document.querySelector('.order-button').style.display = 'none'; /*Пропадает блок с классом .order-button*/