Advertisement
Guest User

Untitled

a guest
Dec 10th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Controller;
  4.  
  5. use Model\User;
  6.  
  7. class AuthController extends Controller
  8. {
  9. public function register()
  10. {
  11. return "auth/register";
  12. }
  13.  
  14. public function login()
  15. {
  16. return "auth/login";
  17. }
  18.  
  19. public function confirmation_notice()
  20. {
  21. return "auth/confirmation_notice";
  22. }
  23.  
  24. public function store()
  25. {
  26. $user = new User($_POST["id"]);
  27. $user->name = $_POST["name"];
  28. $user->surname = $_POST["surname"];
  29. $user->email = $_POST["email"];
  30. $user->password = password_hash($_POST["password"],PASSWORD_BCRYPT);
  31. $user->password_confirmation = $_POST["password_confirmation"];
  32. $user->token= $user->token = bin2hex(openssl_random_pseudo_bytes(16));
  33.  
  34. $this->getStorage()->store($user);
  35.  
  36. if ($_POST['id'])
  37. {
  38. header("location: /auth/confirmation_notice");
  39. }
  40. else if(!$_POST['id'])
  41. {
  42. header("location: /auth/register");
  43. exit;
  44. }
  45. }
  46. }
  47.  
  48.  
  49.  
  50. <h2 class="register">Register</h2>
  51. <?php
  52. use Model\User;
  53. use Storage\MySQLStorage;
  54. $id = $name = $surname = $email = $password = $password_confirmation = "";
  55. // $token = "32";
  56. ?>
  57.  
  58.  
  59. <form method="post" action="/auth/store">
  60. <input type="number" name="id"> Id<br>
  61. <input type="text" name="name"> Name<br>
  62. <input type="text" name="surname"> Surname<br>
  63. <input type="text" name="email"> Email<br>
  64. <input type="text" name="password"> Password<br>
  65. <input type="text" name="password_confirmation"> Password Confirmation<br>
  66. <input type="text" name="token"> Token<br>
  67. <input type="submit" name="Create" value="Create"><br>
  68. </form>
  69.  
  70. <?php
  71.  
  72. echo '<li class="error">The id filed cannot be empty</li>';
  73. echo '<li class="error">The name filed cannot be empty</li>';
  74. echo '<li class="error">The id filed cannot be empty</li>';
  75. echo '<li class="error">The surname filed cannot be empty</li>';
  76. echo '<li class="error">The email filed cannot be empty</li>';
  77. echo '<li class="error">The password filed cannot be empty</li>';
  78. echo '<li class="error">The password confirmation filed cannot be empty</li>';
  79. echo '<li class="error">The password confirmation filed does not match the password field</li>';
  80. echo '<li class="error">The password filed cannot be empty</li>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement