Welcome Guest, Not a member yet? Register   Sign In
validation Custom MSG


i got some doubts. about validation Library.

this is my login function
function Login()
$rules['username'] = "required";
$rules['password'] = "required";
     $fields['username'] = 'Username';
    $fields['password'] = 'Password';
    if ($this->validation->run() == FALSE)
         $this->db->where('username', $_POST['username']);
         $this->db->where('password', $_POST['password']);
     $query =$this->db->get('member');
     if ($query->num_rows() > 0){
        $row = $query->row();
        $data = array(
        'username' => $_POST['username'],
        'id'       => $row->id,
        'logged_in' => TRUE

i wanna send a Custom Msg when Username and Password dont match. how can i do this?

i added this
$this->validation->set_message('macth', 'Username and password don macth');

but dont work!


The validation class can't be used to spit out messages in the way you're trying. It will return the error message if one of the rules fails - right now, the only check you are putting on a username is that it must be filled in. If you want to include checking that it is also correct you need to use a callback function. See the section in the user guide for the validation class for examples on how to do it.

- K

Theme © iAndrew 2016 - Forum software by © MyBB