EllisLab text mark
Advanced Search
     
Error update
Posted: 09 October 2012 08:46 AM   [ Ignore ]
Avatar
Joined: 2012-10-02
71 posts

Hi everyone!
I currently have this code

controller

$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

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

//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.

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

Need help over here.