I created this registration form to register new users on a website using CodeIgniter. My problem is that whenever I enter a username that already exists in my database, instead of giving me my error message that explains this to the user, it instead gives me this error message:
Unable to access error message matching your field name
Here are the code snippets of my controller. Any help would 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 body here } 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; } }
php callback mysql codeigniter
Anthony
source share