D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
ci_panel
/
application
/
controllers
/
admin
/
Filename :
Change_pass.php
back
Copy
<?php class Change_pass extends CI_controller{ public function __construct(){ parent::__construct(); $admin = $this->session->userdata('admin'); if(empty($admin)){ $this->session->set_flashdata('msg', 'Your session has been expired'); redirect(base_url('admin/login/index')); } } public function index() { # code... $this->load->library('form_validation'); $this->load->view('admin/change_pass'); } public function change_pass() { # code... $data=[]; $this->load->library('form_validation'); $this->load->model('Admin_model'); $this->form_validation->set_rules('op', 'Old Password', 'trim|required'); $this->form_validation->set_rules('np', 'New Password', 'trim|required'); $this->form_validation->set_rules('cnp', 'Confirm New Password', 'trim|required'); if($this->form_validation->run()==true){ // getting email form session---> $admin = $this->session->userdata('admin'); $email = $admin['admin_email']; $admin = $this->Admin_model->getByEmail($email); if(!empty($admin)){ $salt = "softproindia2022"; $pass_op = $this->input->post('op'); $temp_op = $pass_op.$salt; $op = md5($temp_op); if($op == $admin['password']){ $pass_np = $this->input->post('np'); $temp_np = $pass_np.$salt; $np = md5($temp_np); $pass_cnp = $this->input->post('cnp'); $temp_cnp = $pass_cnp.$salt; $cnp = md5($temp_cnp); if($np==$cnp){ $newPass['password']=$np; $this->Admin_model->chagne_pass($email, $newPass); redirect(base_url('admin/login/logout')); }else{ $this->session->set_flashdata('msg', 'New password and confirm new password not matched'); redirect(base_url('admin/change_pass/index')); } }else{ $this->session->set_flashdata('msg', 'Incorrect old password'); redirect(base_url('admin/change_pass/index')); } }else{ redirect(base_url('admin/login/logout')); } }else{ $this->session->set_flashdata('msg', 'Sorry, something went wrong!'); redirect(base_url('admin/change_pass/index')); } } }