• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation

#6
[eluser]Bramme[/eluser]
These are the rules of my profile editting form (not much profile info, just a name, email, login name and optional password changing).

Code:
$rules['name'] = 'required';
$rules['login'] = 'required';
$rules['email'] = 'required|valid_email';
$rules['curr_pw'] = 'callback_matches_curr_pw';
$rules['new_pw'] = 'matches[new_pw_check]';

Using these rules, the password changing is not required, but if they are set, they do get validated...


If you're interested in my custom callback method:
Code:
function matches_curr_pw($str) {
        if(empty($str)) {
            return true;
        } else {
            $curr_pw = md5($str);
            $this->db->where('ID', $this->session->userdata('user_id'));
            $qry = $this->db->get('users');
            $row = $qry->row_array();
            $db_pw = $row['paswoord'];
            if($curr_pw == $db_pw) {
                return true;
            } else {
                $this->validation->set_message('matches_curr_pw', 'Het %s veld komt niet overeen met het paswoord in de database.');
                return false;
            }    
        }
    }


Messages In This Thread
Validation - by El Forum - 07-02-2008, 01:38 AM
Validation - by El Forum - 07-02-2008, 03:59 AM
Validation - by El Forum - 07-02-2008, 07:46 AM
Validation - by El Forum - 07-02-2008, 09:56 AM
Validation - by El Forum - 07-02-2008, 10:05 AM
Validation - by El Forum - 07-02-2008, 10:12 AM
Validation - by El Forum - 07-02-2008, 10:12 AM
Validation - by El Forum - 07-02-2008, 10:20 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.