forgot.php 1.1 KB

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