<!DOCTYPE html>
<html>
<head>
<title>reg</title>
</head>
<body>
<form method="post" action="signup.php">
<strong><p>Имя:</p></strong>
<input type="name" name="name" placeholder="Иван" required="required"><br><br>
<strong><p>Фамилия:</p></strong>
<input type="name" name="surname" placeholder="Иванов" required="required"><br><br>
<strong><p>Почта:</p></strong>
<input type="email" name="mail" placeholder="example@res.ru" required="required"><br><br>
<strong><p>Телефон:</p></strong><br>
<input type="tel" name="tel" placeholder="(999)-999-99-99" required="required"><br><br>
<strong><p>Код страны:</p></strong><br>
<input type="tel" name="tel2" placeholder="+7" required="required"><br><br>
<strong><p>Пароль:</p></strong>
<input type="password" name="password" placeholder="555555" required="required"><br><br>
<strong><p>Повторите пароль:</p></strong><br>
<input type="password" name="password2" placeholder="555555" required="required"><br><br>
<input type="hidden" name="id">
<strong><p>Страна:</p></strong>
<select name="select" required="required">
<option>-</option>
<optgroup label="Евразия">
<option value="r1">Россия</option>
</optgroup>
<optgroup label="Северная Америка">
<option value="r1">США</option>
<option value="r2">Канада</option>
</optgroup>
<optgroup></optgroup>
</select><br><br>
<button type="submit" name="i">Зарегистрироваться</button>
</form>
</body>
</html>
<?php
$data = date('YmdHis');
//3xZqPaCO;
$db = mysqli_connect('localhost','','','') or die(mysqli_error());
$name = mysqli_real_escape_string(htmlspecialchars($db, trim($_POST['name'])));
$select = mysqli_real_escape_string(htmlspecialchars($db, trim($_POST['select'])));
$id = $_POST['id'];
$surname = mysqli_real_escape_string(htmlspecialchars($db, trim($_POST['surname'])));
$mail = mysqli_real_escape_string(htmlspecialchars($db, trim($_POST['mail'])));
$tel = mysqli_real_escape_string(htmlspecialchars($db, trim($_POST['tel'])));
$tel2 = mysqli_real_escape_string(htmlspecialchars($db, trim($_POST['tel2'])));
$password0 = $_POST['password'];
$password1 = $_POST['password2'];
if(isset($_POST['i'])){
echo "Кнопка нажата";
if ($password0 == $password1) {
$password2 = mysqli_real_escape_string(htmlspecialchars($db, trim(password_hash($_POST['password'], PASSWORD_DEFAULT))));
$conn = mysqli_query($db, "SELECT FROM res mail");
if ($mail != $conn) {
$conn4 = mysqli_query($db, "SELECT FROM res tel2");
if ($tel != $conn4) {
$query = mysqli_query($db, "INSERT INTO res (id, name, surname, mail, tel, tel2, password, country, data) VALUES('','$name','$surname','$mail','$tel2','$tel','$password','$select','$data') ");
echo "<div style='color:green;'>Вы успешно зарегистрировались</div>";
}else{
echo "Пользователь с таким номером телефона уже существует!";
}
}
}else{
echo "Пароли не совпадают!";
}
}