Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Untuk di Controller
- public function update_password()
- {
- $this->load->model('m_auth');
- $user = $this->session->userdata('username');
- $opass = $this->input->post('old_password');
- $npass = $this->input->post('new_password');
- $rpass = $this->input->post('repeat_password');
- $cek = $this->m_auth->cek_username($user,'user');
- if($rpass == $npass){
- if($cek->num_rows() > 0){
- $row = $cek->row();
- if($opass == $row->password){
- $data = array('password' => md5($npass));
- $this->m_auth->ganti_password($user,$data,'user');
- redirect('lokasi redirect setelah berhasil ganti password');
- }else{
- }
- }else{
- }
- }else{
- }
- }
- //Untuk Di Model
- function cek_user($user,$table){
- $this->db->where('username',$table);
- return $this->db->get($table);
- }
- function ganti_password($user,$data,$table){
- $this->db->where('usermae',$user);
- $this->db->update($table,$data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement