Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Controller_SignUp extends Controller {
- public function action_index()
- {
- if ($_POST)
- {
- $validation = Validation::factory( $_POST )
- ->rule( 'username', 'not_empty' )
- ->rule( 'username', 'max_length', array( ':value', 32 ) )
- ->rule( 'username', 'alpha_dash', array( ':value', true ) ) // Alphabetical characters (from UTF-8), numbers, underscores and dashes...
- ->rule( 'password', 'not_empty' )
- ->rule( 'password', 'min_length', array( ':value', 6 ) )
- ->rule( 'password', 'max_length', array( ':value', 255 ) )
- ->rule( 'passwordRepeatedly', 'not_empty' )
- ->rule( 'passwordRepeatedly', 'matches', array( ':validation', 'passwordRepeatedly', 'password' ) )
- ->rule( 'email', 'not_empty' )
- ->rule( 'email', 'email' );
- if ( $validation->check() )
- {
- $this->response->body( 'All okey!' );
- }
- else
- {
- $this->response->body(
- View::factory( 'a11n/signUp' )
- ->set( 'errors', $validation->errors( 'errorMessages' ) )
- );
- }
- }
- else
- {
- $this->response->body( View::factory( 'a11n/signUp' ) );
- }
- }
- }
Add Comment
Please, Sign In to add comment