Guest User

Untitled

a guest
Jan 4th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2.  
  3. class Controller_signUp extends Controller_Template {
  4.  
  5. function action_index() {
  6.  
  7. $this->template->title = 'Sign Up';
  8. $this->template->content = View::factory( 'signUp/index' );
  9.  
  10. }
  11.  
  12. function action_process() {
  13.  
  14. $username = Input::post( 'username' );
  15. $password = Input::post( 'password' );
  16. $passwordRepeatedly = Input::post( 'passwordRepeatedly' );
  17. $email = Input::post( 'email' );
  18.  
  19.  
  20. $validation = Validation::factory();
  21.  
  22. $validation
  23. ->add( 'username', 'username' )
  24. ->add_rule( 'required' )
  25. ->add_rule( 'max_length', 32 )
  26. ->add_rule( 'valid_string', array( 'alpha', 'numeric', 'punctuation', 'dashes' ) )
  27. ->add( 'password', 'password' )
  28. ->add_rule( 'required' )
  29. ->add_rule( 'min_length', 6 )
  30. ->add_rule( 'max_length', 255 )
  31. ->add( 'passwordRepeatedly', 'password (repeatedly)' )
  32. ->add_rule( 'required' )
  33. ->add_rule( 'match_value', 'password' )
  34. ->add( 'email', 'e-mail' )
  35. ->add_rule( 'required' )
  36. ->add_rule( 'valid_email' );
  37.  
  38.  
  39. if( $validation->run() ) {
  40.  
  41. Session::set_flash( 'notification', 'You have been successfully signed-up! Thanks...' );
  42. Session::set_flash( 'location', 'sign-in' );
  43.  
  44. $this->response->redirect( 'notification' );
  45.  
  46. } else {
  47.  
  48. Session::set_flash( 'error', 'There was something wrong with validation! Try again...' );
  49.  
  50. $this->response->redirect( 'sign-up' );
  51.  
  52. }
  53.  
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment