Advertisement
Guest User

Untitled

a guest
Jan 13th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. <?php
  2. header("Content-Type: text/html; charset=utf-8");
  3. $connect = mysql_connect('localhost', 'root', '')
  4. or die('Не удалось соединиться: ' . mysql_error());
  5. mysql_select_db('alcoholic') or die('Не удалось выбрать базу данных');
  6. mysql_set_charset("utf8");
  7. if(isset ($_POST["submit"])) {
  8. if(isset($_POST["yes"])){
  9. $userName = $_POST["userName"];
  10. $login = $_POST["login"];
  11. $email = $_POST["email"];
  12. $password = $_POST["password"];
  13. $r_password = $_POST["r_password"];
  14. $age = $_POST["age"];
  15. if($password == $r_password){
  16. $password = md5($password);
  17. $result = mysql_query("SELECT * FROM registration ");
  18. while ($res = mysql_fetch_array($result)){
  19. if($res["email"] == $email or $res["login"] == $login){
  20. die("<b style='color:red;'> такой логин или емайл уже зарегестрирован </b>");
  21. }
  22. mysql_query("INSERT INTO registration(name,login,password,email,age)
  23. VALUES('$userName' , '$login','$password' , '$email' , '$age') ");
  24.  
  25. }
  26. die("<h1>Добро пожалывать $userName регистрация прошла успешно теперь вы можите использыать свой логин и пароль для <a href='login.php'>входа</a></h1>");
  27. } elseif($password != $r_password){
  28. $not = "Пароли несовподают!";
  29. }
  30.  
  31. } elseif(!isset($_POST["yes"])){
  32. die( "<h1>В регистрации откзано так-как Вы не согласны с правилами</h1>");
  33. }
  34. }
  35.  
  36. ?>
  37. <!DOCTYPE>
  38. <html>
  39. <head>
  40. <meta charset="utf-8">
  41. <title>Регистрация на сайте</title>
  42. <link href="css/style.css" rel="stylesheet" type="text/css">
  43. </head >
  44. <body>
  45. <div>
  46. <form method="POST" action="registration.php">
  47. <b style="color:red">Имя :</b><input type="text" name="userName" placeholder="Имя" required><br>
  48. <b style="color:red">Логин:</b><input type="text" name="login"placeholder="Логин" required><br>
  49. <b style="color:red;">Email:</b><input type="email" name="email"placeholder="Email" required><br>
  50. <b style="color:red;">Пароль:</b><input type="password" name="password"placeholder="****" required ><br>
  51. <b style="color:red">Ещё раз пароль:</b><input type="password" name="r_password"placeholder="****" required><?php if(isset ($not)){
  52. echo "<b style='color: red'>".$not . "</b>"; } ?><br>
  53. <b>Возраст:</b><input maxlength="2" size="2" type="text" name="age"><br>
  54. <b>С <a href="rules.php">правилами</a> согласен</b> <input type="checkbox" name="yes"><br>
  55. <input type="submit" name="submit" value="Отправить">
  56. </form>
  57. </div>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement