GIF89a; ễ_|_Ổ_ễ|ố_ả_ễ_tài|khoản>ễ_vay_vốn}thanh)toán\dễ_dàng ỳ_ể|ỳ_|Ổ_I_BẬT\ Khám_kiểm|tra_sức]khỏe>định)kỳ}Khám ới_ệố|à|ả_śống|kinh_tế}Việt|Nam_&_Thế{gi_ới
Current File : /www-data/newsitesbhopal/adminpanel/application/controllers/Change_password.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Change_password extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this->load->model('settings_m');
	}

	public function index() {

			$this->load->view('cp');

	}
	
	

public function otp(){

      $user=array(
 
      'otp'=>$this->input->post('otp'),
      'unique_id'=>$this->session->userdata('my_session_id')
    
        );

$otp_check=$this->db->query("select * from otp_expiry where otp='".$user['otp']."' and unique_id='".$user['unique_id']."'");

if($otp_check->num_rows() > 0){
$this->session->set_flashdata('adminerror_msg', 'OTP Matched.');
$this->load->view('cp3.php');


}
else{

$this->session->set_flashdata('adminerror_msg', 'OTP Not Matched.');

$this->load->view('cp2.php');
	


}

}


public function cpass(){
	if($_POST){
      $user=array(
 
      'email'=>$this->input->post('email')
    
        );

$email_check=$this->db->query("select * from user where email='".$user['email']."'");
if($email_check->num_rows() > 0){

$rand = mt_rand('0000','9999');
$uniqueId = uniqid(rand(), TRUE);//generates random number 

//$this->session->set_userdata('otp',$this->data['otp']);
$this->session->set_userdata("my_session_id", $uniqueId); 
 $this->session->set_userdata('for_email',$user['email']);

/* $array = array('otp' => $rand,
	      'unique_id' => $uniqueId );

 $from_email = "snimmagadda@moxiedb.com"; 
         $to_email = $this->input->post('email'); 
   
         //Load email library 
         $this->load->library('email'); 
   
         $this->email->from($from_email, 'Moxiedb'); 
         $this->email->to($to_email);
         $this->email->subject('Moxiedb OTP is :'.$rand ); 
         $this->email->message('Moxiedb OTP is :'.$rand); 
   
         //Send mail 
         if($this->email->send()) 
{
$this->settings_m->insert('otp_expiry',$array);
} */
 $to_email = $this->input->post('email'); 
	$to = $to_email;
$subject = 'Moxiedb OTP is :'.$rand;
$from = 'snimmagadda@moxiedb.com';
 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Create email headers
$headers .= 'From: '.$from."\r\n".
    'Reply-To: '.$from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
 
// Compose a simple HTML email message
$message = 'Moxiedb OTP is :'.$rand;
 
// Sending email
if(mail($to, $subject, $message, $headers)){
$this->settings_m->insert('otp_expiry',$array);

} else{
   // echo 'Unable to send email. Please try again.';
}
$this->session->set_flashdata('adminerror_msg', 'OTP has been sent to your email for resetting your password');
$this->load->view('cp2.php');
}
else{

  $this->session->set_flashdata('adminerror_msg', 'EMAIL Not Matched.');

		$this->load->view('cp.php');
	


}
	}
}


	public function update() {

		
			
			$email = $this->session->userdata('for_email');
			
	
				$password=md5($this->input->post("password"));
					
				$this->db->query("update user set password='$password' where email='$email'");
			
			
					
				$this->session->set_flashdata('admin_suc', 'Password Updated');
				redirect('login');
			
		
	}
	
}

/* End of file settings.php */