<!DOCTYPE html>
<html lang='ru'>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Форма регистрации</title>
</head>
<body>
<?
require('connect.php');
if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['messenger']) && isset($_POST['phone']) && isset($_POST['company'])){
$name = $_POST['name'];
$email = $_POST['email'];
$messenger = $_POST['messenger'];
$phone = $_POST['phone'];
$company = $_POST['company'];
if (preg_match("/[a-zA-Z]/",$_POST['name'])){
$name = $_POST['name'];}
else
{$name = FALSE; echo 'Mожет содержать только буквы латинского алфавита';}
if (preg_match("/\b[\w. -]+@[\w. -]+\.[A-Za-z]{2,6}\b/",$_POST['email'])){
$email = $_POST['email'];}
else
{$email = FALSE; echo 'Емейл введен некорректно';}
if (preg_match("/[()+-\s\d]/",$_POST['phone'])){
$phone = $_POST['phone'];}
else
{$phone = FALSE; echo 'Телефон введен некорректно';}
if (preg_match("/[a-zA-Z\s]/",$_POST['company'])){
$company = $_POST['company'];}
else
{$company = FALSE; echo 'Имя компании введено некорректно';}
$query = "INSERT INTO usersdata (name, email, messenger, phone,company) VALUES ('$name', '$email', '$messenger', '$phone', '$company')";
$result = mysqli_query($connection, $query);
}
?>
<div class="container">
<h1 align="center">Регистрация</h1>
<form class="form-signin" method="POST">
<label>
<b>Name</b>
</label>
<input type="text" name="name" class="from-control" placeholder="Your name" required>
<label>
<b>Email</b>
</label>
<input type="email" name="email" class="from-control" placeholder="Email" required>
<label>
<b>Messenger</b>
</label>
<p><select size="1" name="messenger" class="from-control" required>
<option value="" disabel selected style='display:none;'>To use as a main contact</option>
<option>Viber</option>
<option>Skype</option>
<option>Telegram</option>
<option>Email</option>
</select>
</p>
<label>
<b>Phone</b>
</label>
<input type="tel" name="phone" class="from-control" placeholder="Phone" required>
<label>
<b>Company name</b>
</label>
<input type="text" name="company" class="from-control" placeholder="Just to know where'r u from" require>
<p>Я согласен с Политикой конфиденциальности и Пользовательским соглашением и согласен получать электронную рассылку от Affise</p>
<input type="checkbox" name="agre" value="yes">
<button type="submit" class="registerbtn">Начать</button>
</form>
</div>
</body>
</html>