File: //home/cafsindia/login_cafsindia_com/application/controllers/Password_change.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Password_change extends Action_controller{
public function __construct(){
parent::__construct('password_change');
$this->collect_base_info();
}
// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
public function index(){
$data['quick_link'] = $this->quick_link;
$data['table_head'] = $this->table_head;
$data['master_pick'] = $this->master_pick;
$data['fliter_list'] = $this->fliter_list;
$this->load->view("$this->control_name/manage",$data);
}
public function check_password(){
$current_password = $this->Module->cryptoEncrypt(md5($this->input->post('current_password')));
$employee_code = $this->session->userdata('employee_code');
$old_password_check_qry = 'select count(prime_employees_id) as rslt_count from cw_employees where employee_code = "'.$employee_code.'" and password = "'.$current_password.'" and trans_status = 1';
$old_password_check_data = $this->db->query("CALL sp_a_run ('SELECT','$old_password_check_qry')");
$old_password_check_rslt = $old_password_check_data->result();
$old_password_check_data->next_result();
$pwd_exit_count = $old_password_check_rslt[0]->rslt_count;
if((int)$pwd_exit_count === 1){
echo json_encode(array('success' => TRUE, 'message' => "Continue to enter new password"));
}else{
echo json_encode(array('success' => FALSE, 'message' => "Invalid password, please enter valid password?"));
}
}
public function save_password(){
$new_password = $this->Module->cryptoEncrypt(md5($this->input->post('new_password')));
$employee_code = $this->session->userdata('employee_code');
$update_pass_query = 'UPDATE cw_employees SET password ="'.$new_password.'" WHERE employee_code = "'. $employee_code.'"';
$this->db->query("CALL sp_a_run ('UPDATE','$update_pass_query')");
$this->session->sess_destroy();
echo json_encode(array('success' => TRUE, 'message' => "Your password is updated successfully"));
}
}
?>