Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. //Untuk di Controller
  2. public function update_password()
  3. {
  4.     $this->load->model('m_auth');
  5.  
  6.     $user = $this->session->userdata('username');
  7.     $opass = $this->input->post('old_password');
  8.     $npass = $this->input->post('new_password');
  9.     $rpass = $this->input->post('repeat_password');
  10.  
  11.     $cek = $this->m_auth->cek_username($user,'user');
  12.  
  13.     if($rpass == $npass){
  14.         if($cek->num_rows() > 0){
  15.             $row = $cek->row();
  16.             if($opass == $row->password){
  17.                 $data = array('password' => md5($npass));
  18.                 $this->m_auth->ganti_password($user,$data,'user');
  19.                 redirect('lokasi redirect setelah berhasil ganti password');
  20.             }else{
  21.  
  22.             }
  23.         }else{
  24.  
  25.         }
  26.     }else{
  27.  
  28.     }
  29. }
  30.  
  31. //Untuk Di Model
  32. function cek_user($user,$table){
  33.     $this->db->where('username',$table);
  34.     return $this->db->get($table);
  35. }
  36.  
  37. function ganti_password($user,$data,$table){
  38.     $this->db->where('usermae',$user);
  39.     $this->db->update($table,$data);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement