Advertisement
Guest User

Untitled

a guest
Aug 9th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. class RegistrationController extends Controller {
  4.  
  5.     public function index() {
  6.         return View::make('registration/index')->with('hello', 'Hello World');
  7.     }
  8.  
  9.     public function make() {
  10.        
  11.         echo "1"; // to wypisuje
  12.  
  13.         if(isset($_POST['submit']) && Token::check(Input::get('token'))) {
  14.             $valid = new Validator();
  15.  
  16.             echo "2"; // tego nie wypisuje
  17.  
  18.             $valid->validate($_POST, array(
  19.                 'username' => array(
  20.                     'required' => true,
  21.                     'min' => 3,
  22.                     'max' => 14,
  23.                     'unique' => 'users'
  24.                 ), 'email' => array(
  25.                     'required' => true,
  26.                     'email' => true,
  27.                     'unique' => 'users'
  28.                 ), 'password' => array(
  29.                     'required' => true,
  30.                     'min' => 6,
  31.                     'max' => 18,
  32.                 ), 'password_repeat' => array(
  33.                     'required' => true,
  34.                     'matches' => 'password'
  35.                 )
  36.             ));
  37.  
  38.             if($valid->passes()) {
  39.  
  40.                 echo "3"; // tego nie wypisuje
  41.  
  42.                 $email = $_POST['email'];
  43.                 $username = $_POST['username'];
  44.                 $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
  45.                
  46.                 $sth =  Model::getInstance()
  47.                         ->insert([ 'email' => $email, 'username' => $username, 'password' => $password ],'users')
  48.                         ->make();
  49.  
  50.                 Redirect::to('/redirect')->with('success', 'You have been successfully registered !');
  51.  
  52.             } else {
  53.                 $errors = Error::get();
  54.                 foreach($errors as $field => $error_value) {
  55.                     echo $error_value[0].'</br>';
  56.                 }
  57.             }
  58.         }
  59.  
  60.     }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement