Welcome Guest, Not a member yet? Register   Sign In
Validation Callback function not working
#1

[eluser]terry101[/eluser]
I currently worked on building verification using the callback function. For some reason the callback function isn’t working. Other verification functions work.
“dbcheck” is the function which isn’t working on the script below. I dont get any errors either.

Controller
Code:
function register(){
        
            $this->load->library('form_validation');
            
            $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|xss_clean|callback_dbcheck');
            $this->form_validation->set_rules('name', 'Name', 'required|min_length[3]|max_length[20]|xss_clean');
            $this->form_validation->set_rules('email', 'E-mail', 'required|min_length[3]|max_length[20]|xss_clean|valid_email');
            $this->form_validation->set_rules('password', 'Password', 'required|min_length[3]|max_length[20]|xss_clean');
            $this->form_validation->set_rules('password_conf', 'Re-type Password', 'required|min_length[3]|max_length[20]|xss_clean|matches[password]');
    
            if ($this->form_validation->run() == FALSE) {
            
                $this->load->view('viewregister');
            }
                else {
                $username = $this->input->post('username');
                $name = $this->input->post ('name');
                $email = $this->input->post ('email');
                $password = $this->input->post ('password');
                $this->Usermodel->register_user($username,$name, $email, $password);
                
                echo " you have been registered $username";
                
            }
        }
        
            function dbcheck ($username) {

            $checkusername = array('username' => $username);
            $verifyusername = $this->db->get_where('tbregister', $checkusername);
            if ($verifyusername->num_rows == 1) {
                
            $this->form_validation->set_message('dbcheck','%s already exists!');
                return FALSE;
            }
            else {
                
                return TRUE;
            }
        }


Messages In This Thread
Validation Callback function not working - by El Forum - 08-12-2011, 06:50 PM
Validation Callback function not working - by El Forum - 08-12-2011, 07:20 PM
Validation Callback function not working - by El Forum - 08-12-2011, 08:39 PM
Validation Callback function not working - by El Forum - 08-12-2011, 08:43 PM
Validation Callback function not working - by El Forum - 08-12-2011, 09:09 PM
Validation Callback function not working - by El Forum - 08-12-2011, 09:20 PM
Validation Callback function not working - by El Forum - 08-12-2011, 09:40 PM
Validation Callback function not working - by El Forum - 08-12-2011, 09:52 PM
Validation Callback function not working - by El Forum - 08-12-2011, 10:51 PM
Validation Callback function not working - by El Forum - 08-13-2011, 09:55 AM
Validation Callback function not working - by El Forum - 08-13-2011, 10:07 AM
Validation Callback function not working - by El Forum - 08-13-2011, 11:39 AM
Validation Callback function not working - by El Forum - 08-13-2011, 12:14 PM
Validation Callback function not working - by El Forum - 08-13-2011, 01:55 PM
Validation Callback function not working - by El Forum - 08-13-2011, 03:14 PM
Validation Callback function not working - by El Forum - 08-13-2011, 04:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB