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 = '
Wellcome to VoyageGirls.com


Welcome to VoyageGirls.com, your registration was succesful.
Here is you registration data:


Username: '.$values['name'].'
Password: '.$values['password'].' '; Email::send($values['email'], 'voyagegirls@gmail.com', 'no reply', $message, $html = true); }catch(ORM_Validation_Exception $e){ $errors = $e->errors('registration', true); foreach($errors as $value){ echo $value."
"; } } }