reegistration.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. $name = $_POST["name"];
  11. $surname = $_POST["surname"];
  12. $email = $_POST["email"];
  13. $login = $_POST["login"];
  14. $pass = $_POST["password"];
  15. $quary = "SELECT * FROM login WHERE login like'$login'";
  16. $result = mysqli_query($mysql, $quary);
  17. if(mysqli_num_rows($result) > 0)
  18. {
  19. header('Location: Registration.php?message=Логин+существует');
  20. echo "<script>window.location.href = 'Registration.php';</script>";
  21. mysqli_close();
  22. }
  23. $quary = "SELECT * FROM login WHERE email like '$email'";
  24. $result1 = mysqli_query($mysql, $quary);
  25. if(mysqli_num_rows($result1) > 0)
  26. {
  27. header('Location: Registration.php?message=Почта+существует');
  28. echo "<script>window.location.href = 'Registration.php';</script>";
  29. mysqli_close();
  30. }
  31. if(mysqli_num_rows($result) == 0 && mysqli_num_rows($result1) == 0)
  32. {
  33. $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  34. $kod = substr(str_shuffle($permitted_chars), 0, 10);
  35. $message = "Проверочный код: ".$kod;
  36. $to = $email;
  37. $from = "provalenkoludmila@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['name'] = $name;
  44. $_SESSION['surname'] = $surname;
  45. $_SESSION['login'] = $login;
  46. $_SESSION['password'] = $pass;
  47. $_SESSION['email'] = $email;
  48. $_SESSION['kod'] = $kod;
  49. echo "<script>window.location.href = 'EmailCheck.php';</script>";
  50. }
  51. ?>