File: /var/www/html/pmw24/app/application/controllers/customer/Recover_password.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Recover_password extends MY_Controller {
public function __construct() {
parent::__construct();
$this->load->model('admin/mcustomer');
}
public function index(){
$this->forgotpassword();
}
public function forgotpassword($key) {
$data['key'] = $key;
//echo $key; die;
$check_exist_key = $this->mcustomer->getRow('customer',array('recovery_key'=> $key));
//echo $this->db->last_query();die;
//print_r($check_exist_key);die;
if(!empty($check_exist_key)){
$data['link_expired'] = 0;
} else{
$data['link_expired'] = 1;
}
$data['title'] = 'Punjabmotor Workshop';
$this->load->view('forgotpassword_customer', $data);
}
public function recover_account() {
$new_password = $this->input->post('newpassword1');
$recovery_key = $this->input->post('recovery_key');
$result=$this->mcustomer->check_recovery_key($recovery_key);
if($result){
$condition=array('customer_id'=>$result['customer_id']);
$data=array('password'=>md5($new_password),'org_password'=>$new_password,'recovery_key'=>'');
$update_result = $this->mcustomer->update($condition,$data);
if($update_result){
$response = array("status" => true, "message" => "Password Updated Successfully");
}
else{
$response = array("status" => true, "message" => "Some thing went wrong. Please try again");
}
}
else{
$response = array("status" => true, "message" => "Reset link Expired. Please try again.");
}
echo json_encode($response);
}
public function error_404() {
$data['title'] = 'PunjabMotor Workshop';
$this->load->view('error_404');
}
}