Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1. <?php
  2. include("db_connect.php");
  3. $login = '';
  4. $password = '';
  5. $errorLogin = '';
  6. $errorPassword = '';
  7. $password_2 = '';
  8. $errorSamePassword = '';
  9. $registered = '';
  10. $loginNotFree = '';
  11. $reminderKey = '';
  12. $reminderKey_2 = '';
  13. $reminderKeyText = '';
  14. $errorReminderKey = '';
  15.  
  16. if ( isset( $_POST['register'] ) ) {
  17. $login = $_POST['login'];
  18. $password = $_POST['password'];
  19. $password_2 = $_POST['password_2'];
  20. $reminderKey = $_POST['reminderKey'];
  21. $reminderKey_2 = $_POST['reminderKey_2'];
  22. $reminderKeyText = $_POST['reminderKeyText'];
  23.  
  24. if ( $login && strlen($login) < 4 ) {
  25. $errorLogin = 'Login musi zawierać minimum 4 znaki';
  26. }
  27.  
  28. if ( $password && strlen($password) < 6 ) {
  29. $errorPassword = 'Hasło musi zawierać minimum 6 znaków';
  30. }
  31.  
  32. if ( $password != $password_2 ) {
  33. $errorSamePassword = 'Hasło musi być takie samo';
  34. }
  35.  
  36.  
  37. if ( $reminderKey != $reminderKey_2 ) {
  38. $errorReminderKey = 'Odpowiedź musi być taka sama';
  39. }
  40.  
  41. $result = mysqli_query($mysqli,"SELECT * FROM users WHERE login = '$login'");
  42. $countUsers = mysqli_num_rows($result);
  43. if($countUsers>0){
  44. $loginNotFree = 'Login jest już zajęty';
  45. }
  46.  
  47. if(! $errorLogin && ! $errorPassword && ! $errorSamePassword && !$loginNotFree && ! $errorReminderKey)
  48. {
  49. $registered = 1;
  50. }
  51.  
  52.  
  53. }
  54. ?>
  55.  
  56. <!DOCTYPE html>
  57. <html>
  58.  
  59. <head>
  60. <meta charset="utf-8">
  61. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  62. <title>Literature Community</title>
  63. <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
  64. <link rel="stylesheet" href="../fontawesome-free-5.0.13/web-fonts-with-css/css/fontawesome-all.css">
  65. <link rel="stylesheet" href="../css/styles.css">
  66. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
  67. </head>
  68.  
  69. <body>
  70. <div>
  71. <?php include("db_connect.php"); ?>
  72. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="text-center">
  73. <div class="container">
  74. <div class="row">
  75. <div class="col-md-12">
  76. <?php if ( $registered == 1 ) {
  77. $statement = $mysqli->prepare("INSERT users (login,password,reminderKey,reminderKeyText) VALUES (?,?,?,?)");
  78. $statement->bind_param("ssss",$login,$password,$reminderKey,$reminderKeyText);
  79. $statement->execute();
  80. $statement->close(); ?>
  81. <div class="ui message">
  82. <div class="header">Rejestracja przebiegła pomyślnie!</div>
  83. <p>Za chwilę zostaniesz przekierowany na stronę główną</p>
  84. </div>
  85. <?php header( "refresh:5;url=../../index.php" ); } ?>
  86.  
  87. <img src="../img/default-avatar.png" alt="Avatar" class="login-avatar">
  88. </div>
  89.  
  90. <div class="col-md-4 col-md-offset-2">
  91. <label for="login"><b>Login</b></label>
  92. <?php if ( $errorLogin != null) { ?>
  93. <span style="color:black;" class="ui red label">
  94. <?php echo $errorLogin; ?>
  95. </span>
  96. <?php } ?>
  97. <?php if ( $loginNotFree != null) { ?>
  98. <span style="color:black;" class="ui red label">
  99. <?php echo $loginNotFree; ?>
  100. </span>
  101. <?php } ?>
  102. <input class="form-control" type="text" placeholder="Wpisz login" name="login" required>
  103.  
  104. <label for="password"><b>Hasło</b></label>
  105. <?php if ( $errorPassword != null ) { ?>
  106. <span style="color:black;" class="ui red label">
  107. <?php echo $errorPassword; ?>
  108. </span>
  109. <?php } ?>
  110. <input class="form-control" type="password" placeholder="Wpisz hasło" name="password" required>
  111.  
  112. <label for="password"><b>Powtórz hasło</b></label>
  113. <?php if ( $errorSamePassword != null ) { ?>
  114. <span style="color:black;" class="ui red label">
  115. <?php echo $errorSamePassword; ?>
  116. </span>
  117. <?php } ?>
  118. <input class="form-control" type="password" placeholder="Powtórz hasło" name="password_2" required>
  119. </div>
  120.  
  121. <div class="col-md-4">
  122. <label for="reminderKeyText"><b>Pomocnicze pytanie</b></label>
  123. <input class="form-control" type="text" placeholder="Wpisz pomocnicze pytanie" name="reminderKeyText" required>
  124.  
  125. <label for="reminderKey"><b>Odpowiedź na pomocnicze pytanie</b></label>
  126. <input class="form-control" type="text" placeholder="Wpisz odpowiedź na pomocnicze pytanie" name="reminderKey" required>
  127.  
  128. <label for="reminderKey_2"><b>Powtórz odpowiedź na pomocnicze pytanie</b></label>
  129. <?php if ( $errorReminderKey != null) { ?>
  130. <span style="color:black;" class="ui red label">
  131. <?php echo $errorReminderKey; ?>
  132. </span>
  133. <?php } ?>
  134. <input class="form-control" type="text" placeholder="Powtórz odpowiedź na pomocnicze pytanie" name="reminderKey_2" required>
  135. </br>
  136. </div>
  137. <div class="col-md-2"></div>
  138. </div>
  139.  
  140. <button class="btn btn-info" type="submit" name="register">Zarejestruj</button>
  141. </div>
  142. </form>
  143. </div>
  144.  
  145. <script src="../js/jquery.min.js "></script>
  146. <script src="../bootstrap/js/bootstrap.min.js "></script>
  147.  
  148.  
  149. </body>
  150.  
  151. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement