registration.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. $host = "kurek620.beget.tech";
  3. $username = "kurek620_baze";
  4. $password = "6910WASD579h";
  5. $database = "kurek620_baze";
  6. $FIO = $_POST["FIO"];
  7. $region = $_POST["region"];
  8. $login = $_POST["login"];
  9. $Email = $_POST["Email"];
  10. $passwor = $_POST["password"];
  11. $mysql = new mysqli($host, $username, $password, $database);
  12. if($mysql->connect_error){
  13. die("Ошибка подключения". $mysql->connect_error);
  14. }
  15. $quary = "SELECT * FROM Users WHERE login like'$login'";
  16. $result = mysqli_query($mysql, $quary);
  17. if(mysqli_num_rows($result) > 0)
  18. {
  19. header('Location: index.html?message=Логин+существует');
  20. echo "<script>window.location.href = 'index.html';</script>";
  21. mysqli_close();
  22. }
  23. $quary = "SELECT * FROM Users WHERE Email like '$Email'";
  24. $result1 = mysqli_query($mysql, $quary);
  25. if(mysqli_num_rows($result1) > 0)
  26. {
  27. header('Location: index.html?message=Почта+существует');
  28. echo "<script>window.location.href = 'index.html';</script>";
  29. mysqli_close();
  30. }
  31. if(mysqli_num_rows($result) == 0 && mysqli_num_rows($result1) == 0)
  32. {
  33. $permitted_chars = '0123456789';
  34. $kod = substr(str_shuffle($permitted_chars), 0, 5);
  35. $message = "Проверочный код: ".$kod;
  36. $to = $Email;
  37. $from = "Kurlek665@gmail.com";
  38. $subject = "Проверочный код для ".$login;
  39. $subject = "=?utf-8?B?".base64_encode($subject)."?=";
  40. $headers = "From: $from\r\nReply-to: $from\r\nContent-type: text/html; charset=utf-8\r\n";
  41. mail($to, $subject, $message, $headers);
  42. session_start();
  43. $_SESSION['login'] = $login;
  44. $_SESSION['password'] = $passwor;
  45. $_SESSION['Email'] = $Email;
  46. $_SESSION['region'] = $region;
  47. $_SESSION['FIO'] =$FIO;
  48. $_SESSION['kod'] = $kod;
  49. echo "<script>window.location.href = 'EmailCheck.html';</script>";
  50. }
  51. ?>