Advertisement
Guest User

Untitled

a guest
Dec 10th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 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. if(isset($_POST["Create"]))
  12. {
  13. if($_POST["id"]=='')
  14. echo '<li class="error">The id filed cannot be empty</li>';
  15. if($_POST["name"]=='')
  16. echo '<li class="error">The name filed cannot be empty</li>';
  17. if($_POST["surname"]=='')
  18. echo '<li class="error">The surname filed cannot be empty</li>';
  19. if($_POST["password"]=='')
  20. echo '<li class="error">The email filed cannot be empty</li>';
  21. if($_POST["password"]=='')
  22. echo '<li class="error">The password filed cannot be empty</li>';
  23. if($_POST["password_confirmation"]=='')
  24. echo '<li class="error">The password confirmation filed cannot be empty</li>';
  25. if($_POST["id"]!='' && $_POST["name"]!='' && $_POST["surname"]!='' && $_POST["email"]!=''
  26. && $_POST["password"]!='' && $_POST["password_confirmation"]!='')
  27. {
  28. if($_POST["password"] != $_POST["password_confirmation"])
  29. {
  30. echo '<li class="error">TThe password confirmation filed does not match the password field</li>';
  31. return "auth/register";
  32. }
  33.  
  34. else
  35. $this->store();
  36. }
  37. else
  38. return "auth/register";
  39. }
  40. else
  41. return "auth/register";
  42. }
  43.  
  44. public function confirmation_notice()
  45. {
  46. return "auth/confirmation_notice";
  47. }
  48.  
  49. public function store()
  50. {
  51. $user = new User($_POST["id"]);
  52. $user->name = $_POST["name"];
  53. $user->surname = $_POST["surname"];
  54. $user->email = $_POST["email"];
  55. $user->password = password_hash($_POST["password"],PASSWORD_BCRYPT);
  56. $user->password_confirmation = $_POST["password_confirmation"];
  57. $user->token = bin2hex(openssl_random_pseudo_bytes(16));
  58.  
  59. $this->getStorage()->store($user);
  60.  
  61. header("location: /auth/confirmation_notice");
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement