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

#1
[eluser]ninjayan[/eluser]
Hi everyone!
I currently have this code

controller
Code:
$this->form_validation->set_rules('old_password', 'Password', 'required|trim|min_length[4]|max_length[32]');
    $this->form_validation->set_rules('new_password', 'Password', 'required|trim|min_length[4]|max_length[32]');
    $this->form_validation->set_rules('retype_password', 'Password', 'required|trim|min_length[4]|max_length[32]|matches[new_password]');

    if ($this->form_validation->run() == FALSE)
    {
     $password_result['errors'] = validation_errors();
    }
    else
    {
     //PROCEED UPDATING PASSWORD
     $this->load->model('user_update');

     if ($this->user_update->password())
     {
      $password_result['success'] = true;
     }
     else
     {
      $password_result['errors'] = "<p>Unable to update your Password.</p>";
     }
    }

and this
model
Code:
public function password()
{
  $old_password = md5($this->input->post('old_password'));
  $new_password = md5($this->input->post('new_password'));

  //CHECK FIRST IF THE OLD PASSWORD SUBMITTED IS CORRECT
  $this->db->select('password');
  $this->db->from('users');
  $this->db->where('username', $this->session->userdata('username'));
  $this->db->where('password', $old_password);
  $query = $this->db->get();

  if ($query->num_rows() == 1)
  {
   //UPDATE THE PASSWORD
   $data = array('password', $new_password);
   $this->db->where('username', $this->session->userdata('username'));
   $update_query = $this->db->update('users', $data);

   if ($update_query)
   {
    return true;
   }
   else
   {
    return false;
   }
  }
  else
  {
   return false;
  }
}

When I remove the lines
Code:
//UPDATE THE PASSWORD
   $data = array('password', $new_password);
   $this->db->where('username', $this->session->userdata('username'));
   $update_query = $this->db->update('users', $data);

   if ($update_query)
   {
    return true;
   }
   else
   {
    return false;
   }
from the model, it works fine

but when I added the active record for updating, this error message shows at the console.

Code:
http://localhost/dts/site/update_password 500 (Internal Server Error)

Need help over here.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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