Advertisement
Guest User

Untitled

a guest
Dec 10th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 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["submit"]))
  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"]!='' && $_POST["password"]!='' && $_POST["password_confirmation"]!='')
  26. {
  27. $this->store();
  28. }
  29. else
  30. return "auth/register";
  31. }
  32. else
  33. return "auth/register";
  34. }
  35.  
  36. public function confirmation_notice()
  37. {
  38. return "auth/confirmation_notice";
  39. }
  40.  
  41. public function store()
  42. {
  43. $user = new User($_POST["id"]);
  44. $user->name = $_POST["name"];
  45. $user->surname = $_POST["surname"];
  46. $user->email = $_POST["email"];
  47. $user->password = password_hash($_POST["password"],PASSWORD_BCRYPT);
  48. $user->password_confirmation = $_POST["password_confirmation"];
  49. $user->token = bin2hex(openssl_random_pseudo_bytes(16));
  50.  
  51. $this->getStorage()->store($user);
  52. header("location: /auth/confirmation_notice");
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement