session_start();
$connect = mysqli_connect("localhost","","","") or die('Не удалось подключиться');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
$email = $_POST['email'] ;
$login = $_POST['login'];
$password0 = $_POST['password0'];
$salt = "2ert45g6klmnop56891234gb";
$password = $_POST['password'];
$tel = $_POST['tel'];
$id = $_POST['id'];
if (isset($_POST['submit-reg'])) {
if ($password == $password0) {
$hash = password_hash($password, PASSWORD_DEFAULT);
$query = mysqli_query($connect, "SELECT id FROM users WHERE login='$login' LIMIT 1");
$fetch = mysqli_fetch_array($query);
if ($fetch == 0) {
$fill = mysqli_query($connect, "INSERT INTO users (id,tel,email,login,password,reppassword) VALUES ('','$tel','$email','$login','$password','$password0')");
var_dump($fill);
echo "<div style='color:green; font-family: 'Lobster', cursive;'><p style='margin:0; display:inline-block;'>Добро пожаловать,</p>".$login."<p style='margin:0;display:inline-block;'>!</p></div>";
}
}elseif ($fetch != 0) {
echo "<div style='color:red; font-family: 'Lobster', cursive;'>"."<p style='margin:0;'>Пользователь с таким именем уже существует!
</p>"."</div>";
}
}
}
$login2 = $_POST['login2'];
$password2 = $_POST['password2'];
if (isset($_POST['submit-log'])) {
$query2 = "SELECT password FROM users WHERE login ='$login2' LIMIT 1";
var_dump($query2);
$query2 = mysqli_query($connect, $query2);
if( $query2->num_rows ){
if (password_verify($password, $hash)) {
echo "<div style='color:green; font-family: 'Lobster', cursive;'>Вы успешно вошли!</div>";
}else{
echo "<div style='color:red; font-family: 'Lobster', cursive;'>Пароли не совпадают!</div>";
}
}else{
echo "<div style='color:red; font-family: 'Lobster', cursive;'>Пользователь не найден!</div>";
}
}else{
echo "///";
}