daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Controller_SignUp extends Controller {
  4.  
  5.     public function action_index()
  6.     {
  7.         if ($_POST)
  8.         {
  9.             $validation = Validation::factory( $_POST )
  10.                 ->rule( 'username', 'not_empty' )
  11.                 ->rule( 'username', 'max_length', array( ':value', 32 ) )
  12.                 ->rule( 'username', 'alpha_dash', array( ':value', true ) ) // Alphabetical characters (from UTF-8), numbers, underscores and dashes...
  13.                 ->rule( 'password', 'not_empty' )
  14.                 ->rule( 'password', 'min_length', array( ':value', 6 ) )
  15.                 ->rule( 'password', 'max_length', array( ':value', 255 ) )
  16.                 ->rule( 'passwordRepeatedly', 'not_empty' )
  17.                 ->rule( 'passwordRepeatedly', 'matches', array( ':validation', 'passwordRepeatedly', 'password' ) )
  18.                 ->rule( 'email', 'not_empty' )
  19.                 ->rule( 'email', 'email' );
  20.  
  21.             if ( $validation->check() )
  22.             {
  23.                 $this->response->body( 'All okey!' );
  24.             }
  25.             else
  26.             {
  27.                 $this->response->body(
  28.                     View::factory( 'a11n/signUp' )
  29.                         ->set( 'errors', $validation->errors( 'errorMessages' ) )
  30.                 );
  31.             }
  32.         }
  33.         else
  34.         {
  35.             $this->response->body( View::factory( 'a11n/signUp' ) );
  36.         }
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top