Welcome Guest, Not a member yet? Register   Sign In
form_validation error
#1

I'm creating a library to add new users.

Code:
class Register
   {
       private $CI;
       public function add_new_user()
       {
           $CI =& get_instance();
           $CI->form_validation->set_rules('email', 'Email', 'required|callback_is_email_exist');
           if ($CI->form_validation->run() == TRUE)
           {
               $email = $_POST['email'];
               $insert_data = array('email' => $email);
               $CI->new_data->add_user($insert_data);
           }
       }
       private function is_email_exist($email)
       {
           $CI =& get_instance();
           $email_result = '';
           $query = $CI->check->find_email($email);
           foreach ($query->result_array() as $row)
           {
               $email_result = $row['email'];
           }
           if ($email_result == $email)
           {
               $CI->form_validation->set_message('is_email_exist', 'Such email already exist!');
               return FALSE;
           }
           else
           {
               return TRUE;
           }
       }
   }
I add form_validation and models check, new_data to the autoload. When I submit a form instead of an error (if it should be there) I get Unable to access an error message corresponding to your field name Username.(is_username_exist). What should i do to fix this?
Reply


Messages In This Thread
form_validation error - by Stormkeeper - 08-24-2017, 08:33 AM
RE: form_validation error - by InsiteFX - 08-25-2017, 04:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB