I have working registration script the only problem is that i do not know how to check if username already exist because now if email or username already exist it returns me this fatal error: ORM_Validation_Exception [ 0 ]: Failed to validate array ~ MODPATH/orm/classes/kohana/orm.php [ 1174 ]
And here is my script:
$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')
if(!$validate->check()){
$errors = $validate->errors('registration', true);
foreach($errors as $value){
echo $value . "<br />";
}
return;
}
$model = ORM::factory('user');
$model->values(array(
'username' => $values['name'],
'email' => $values['email'],
'password' => $values['password'],
'password_confirm' => $values['repeat-password'],
));
Im using 3.2 version.
To find out if an entry exists...
$model = ORM::factory('user', $values['name']);
if ( !$model->is_loaded() ) {
// do registration
}
This will try to search for a user model with that username (if it is set to your primary key).