public function action_register(){ parse_str($_POST['data'], $values);//convert data in to normal array $auto_render = false; if($_POST['action'] == 'get_form'){//render registration window $form = View::factory("home/registration"); $page = $form->render(); $this->response->body($page); }else{//validate registration try{ $user = ORM::factory('user'); $validate = Validation::factory($values) ->rule('name', 'not_empty') ->rule('password', 'matches', array(':validation', 'password', 'repeat-password')) ->rule('password', 'not_empty') ->rule('email', 'email')->rule('email', 'not_empty') ->rule('about-me', 'max_length', array(':value', 300)); $user->values(array( 'username' => $values['name'], 'email' => $values['email'], 'password' => $values['password'], 'password_confirm' => $values['repeat-password'], 'age' => $value['date'], 'country' => $value['Country'], 'city' => $value['city'], 'height' => $value['height'], 'body' => $value['body-type'], 'eyes' => $value['eyes'], 'hair' => $value['hair'], 'about_me' => $value['about-me'] )); $user->save(); // remember to add the login role AND the admin roles // add a role; add() executes the query immediatelys $model->add('roles', ORM::factory('role')->where('name', '=', 'login')->find()); echo 'Registration was successful'; Auth::instance()->login($values['name'], $values['password']); $mailer = Email::connect(); $message = '