Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class RegistrationController extends Controller {
- public function index() {
- return View::make('registration/index')->with('hello', 'Hello World');
- }
- public function make() {
- echo "1"; // to wypisuje
- if(isset($_POST['submit']) && Token::check(Input::get('token'))) {
- $valid = new Validator();
- echo "2"; // tego nie wypisuje
- $valid->validate($_POST, array(
- 'username' => array(
- 'required' => true,
- 'min' => 3,
- 'max' => 14,
- 'unique' => 'users'
- ), 'email' => array(
- 'required' => true,
- 'email' => true,
- 'unique' => 'users'
- ), 'password' => array(
- 'required' => true,
- 'min' => 6,
- 'max' => 18,
- ), 'password_repeat' => array(
- 'required' => true,
- 'matches' => 'password'
- )
- ));
- if($valid->passes()) {
- echo "3"; // tego nie wypisuje
- $email = $_POST['email'];
- $username = $_POST['username'];
- $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
- $sth = Model::getInstance()
- ->insert([ 'email' => $email, 'username' => $username, 'password' => $password ],'users')
- ->make();
- Redirect::to('/redirect')->with('success', 'You have been successfully registered !');
- } else {
- $errors = Error::get();
- foreach($errors as $field => $error_value) {
- echo $error_value[0].'</br>';
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement