Email.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. $host = "provalgk.beget.tech";
  3. $username = "provalgk_user";
  4. $password = "Qwer123.";
  5. $database = "provalgk_user";
  6. $mysql = new mysqli($host, $username, $password, $database);
  7. // Проверка соединения
  8. if ($mysql->connect_error) {
  9. die("Ошибка подключения: " . $mysql->connect_error);
  10. }
  11. $user = $_POST['login'];
  12. $email = $_POST['email'];
  13. $quary = "SELECT * FROM Login WHERE login like'$user'";
  14. $result = mysqli_query($mysql, $quary);
  15. $row = mysqli_fetch_assoc($result);
  16. $emaill = $row['email'];
  17. if($email == $emaill)
  18. {
  19. $message = "Ваш пароль: ".$row["password"];
  20. $to = $email;
  21. $from = "provalenkoludmila@gmail.com";
  22. $subject = "Восстановление пароля";
  23. $subject = "=?utf-8?B?".base64_encode($subject)."?=";
  24. $headers = "From: $from\r\nReply-to: $from\r\nContent-type: text/html; charset=utf-8\r\n";
  25. mail($to, $subject, $message, $headers);
  26. echo "<script>window.location.href = 'Login.html';</script>";
  27. }
  28. else
  29. {
  30. header('Location: Email.html?message=Неверные+данные');
  31. echo "<script>window.location.href = 'Email.html';</script>";
  32. mysqli_close();
  33. }
  34. ?>