views:

301

answers:

0

Hi, I've created this registration form for registering new users to a website using CodeIgniter. My problem is, whenever I enter a username that already exists in my database, instead of giving me my error message which explains this to the user, it instead gives me this error message:

Unable to access an error message corresponding to your field name

Here are snippets of the code from my controller. Any assistance will be appreciated:

function register(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username','trim|required|alpha_numeric|min_length[6]|xss_clean|strtolower|callback_username_not_exists);
...
}
function username_not_exists($username)
{
$this->form_validation->set_message('username','That %s already exists.');
if($this->User_model->check_exists_username($username))
{
return false;
}
else
{
return true;
}