<?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);
}


$user = $_POST['login'];
$email = $_POST['email'];

$quary = "SELECT * FROM login WHERE login like'$user'";
$result = mysqli_query($mysql, $quary);
$row = mysqli_fetch_assoc($result);
$emaill = $row['email'];

if($email == $emaill)
{
$message = "Ваш пароль: ".$row["password"];
$to = $email;
$from = "provalenkoludmila@gmail.com";
$subject = "Восстановление пароля";
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
$headers = "From: $from\r\nReply-to: $from\r\nContent-type: text/html; charset=utf-8\r\n";
mail($to, $subject, $message, $headers);
echo "<script>window.location.href = 'formLogin.php';</script>";
}
else
{
    header('Location: forgotpassword.php?message=Неверные+данные');
    echo "<script>window.location.href = 'forgotpassword.php';</script>";
    mysqli_close();
}
?>