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

#1
[eluser]Loquela[/eluser]
Hi there,

For some reason, the md5 is not converting the email input and the data is submitted as plan text. Everything elseworks, validation is working - I'm sent back to the form on falure and the data is inserted on success. Just the md5 function in the password field doesn't seem to be doing anything.

Any ideas?

Cheers

Code:
$this->form_validation->set_rules('username', 'Username', 'required');
        
        $this->form_validation->set_rules('password', 'Password', 'matches[passconf]|md5');
      
        $this->form_validation->set_rules('passconf', 'Retype password');
        $this->form_validation->set_rules('firstname', 'Firstname', 'required');
        $this->form_validation->set_rules('lastname', 'lastname', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
        
        $data = array(
            'username'  =>$this->input->post('username'),
            'password'  =>$this->input->post('password'),
            'firstname' =>$this->input->post('firstname'),
            'lastname'  =>$this->input->post('lastname'),
            'email'     =>$this->input->post('email'),
            'updated'    =>$this->input->post('updated'),
        
        );
        
        
        if($this->form_validation->run()==FALSE)
        {
            $this->update_admin_form($data);
        }
        else
        {
            $this->users_model->update_user($data);
            $this->update_admin_form($data);
        }
    }

#2
[eluser]danmontgomery[/eluser]
md5 only gets applied on the successful completion of $this->form_validation->run(), so you would need to declare the $data array after that call.

Code:
if($this->form_validation->run()==FALSE)
{
  ...
}
else
{
  $data = array(
   'username'  =>$this->input->post('username'),
   'password'  =>$this->input->post('password'),
   'firstname' =>$this->input->post('firstname'),
   'lastname'  =>$this->input->post('lastname'),
   'email'     =>$this->input->post('email'),
   'updated'    =>$this->input->post('updated'),
  );

  $this->update_admin_form($data);
}

#3
[eluser]Loquela[/eluser]
Thanks nocturn,

that did the trick.

L.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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