Welcome Guest, Not a member yet? Register   Sign In
Validation
#10

[eluser]schnoodles[/eluser]
Not exactly, i cant use a standard callback because i want to compare USERNAME and PASSWORD in one hit. I have found a way around it although i am not sure if its the best way.

in Password Rules i use login_match[username] and the code i have is

Code:
<?php

    class MY_Validation extends CI_Validation {

        public function My_Validation()
        {
            parent::CI_Validation();
        }
        
       /*
        * Add login_match[username] to your
        * password rules.
        */
      
        public function login_match($str,$field)
        {
            if ( ! isset($_POST[$field]))
            {
                return FALSE;
            }
        
            $this->CI->load->model('jb_usermodel');
            $user = new jb_usermodel();
            
            if ( !$user->hasUser($_POST[$field],$str) && sizeof($this->_error_array) == 0)
            {
                $this->set_message('login_match', 'Your username or password is incorrect');
                return FALSE;
            }
            
            return TRUE;
        }
    
    }

?>

Hopefully that will give everyone a better idea of what i am trying to accomplish there. If anyone has a better way of doing this maybe without subclassing the Validation class i would love to hear it.


Messages In This Thread
Validation - by El Forum - 10-22-2007, 03:49 AM
Validation - by El Forum - 10-22-2007, 05:17 AM
Validation - by El Forum - 10-22-2007, 07:02 AM
Validation - by El Forum - 10-22-2007, 03:02 PM
Validation - by El Forum - 10-22-2007, 03:40 PM
Validation - by El Forum - 10-22-2007, 05:27 PM
Validation - by El Forum - 10-22-2007, 06:15 PM
Validation - by El Forum - 10-22-2007, 07:16 PM
Validation - by El Forum - 10-23-2007, 07:11 AM
Validation - by El Forum - 10-23-2007, 05:47 PM
Validation - by El Forum - 10-24-2007, 12:47 AM
Validation - by El Forum - 10-24-2007, 01:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB