<?php
$host = "blueris.beget.tech";
$username = "blueris_base";
$password = "Qwer123.";
$database = "blueris_base";
$mysql = new mysqli($host, $username, $password, $database);


if($mysql->connect_error){
    die("Ошибка подключения". $mysql->connect_error);
}

$kod = $_POST["check"];

session_start();
$name = $_SESSION['name'];
$surname = $_SESSION['surname'];
$login = $_SESSION['login'];
$pass = $_SESSION['password'];
$email = $_SESSION['email'];

if($kod == $_SESSION['kod'])
{
    $query = "INSERT INTO login (`name`,`lastname`,`login`, `email`, `password`) VALUES ('$name', '$surname', '$login', '$email', '$pass')";
    if($result = $mysql->query($query))
    {
        $_SESSION['name'] = $name;
        $_SESSION['surname'] = $surname;
        $_SESSION['login'] = $login;
        $_SESSION['password'] = $pass;
        $_SESSION['email'] = $email;
        echo "<script>window.location.href = 'formLogin.php';</script>";
    }      
}
else
        header('Location: EmailCheck.php?message=Неверный+код');
        echo "<script>window.location.href = 'EmailCheck.php';</script>";
        mysqli_close();
?>