Monday, March 4, 2013

How ?? Lost Password With CI

Script Codeigniter :
1. Create class clogin.php
scrip:
<?php
class clogin extends CI_Controller {
   
    //action
    function _construct(){
        parent::_construct();
        $this->load->model('mlogin');
        $this->load->library('session');
        $this->load->library('encrypt');
        $this->load->library('upload');
        $this->load->model('mlogin');
        $this->load->helper(array('form', 'url'));
       
       
    }
 function lost(){
        if ($this->input->post('lost')){
          
            $this->mlogin->lostpassword();
            redirect('index.php/clogin','refresh');
        }
        else{
            echo 'Lost Password Gagal';
        }
    }
}
?>

2. Create class model mlogin
script :
<?php
class mlogin extends CI_Model {
function lostpassword(){
        $email = $this->input->post('email');
        $query="Select * From login WHERE email='$email'";
       
        $cek=$this->db->query($query);
       
        if($cek->num_rows()>0){
            $this->load->library('email');
            $email=$this->input->post('email');
           
                $jml_code = 5;
                $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                $max = strlen($source)-1;
               
                $codeUpdate = "";
                mt_srand((double)microtime()*1000000);
                while(strlen($codeUpdate)<$jml_code)
                $codeUpdate .= $source{
                    mt_rand(0,$max)
                };
            $update='NotUpdate';
            $body='Welcome'.' '.$email.',
            Anda telah melakukan lost-password, Silahkan klik link di bawah ini untuk reset password akun Anda.
            http://festiware.com/endang_ci/index.php/clogin/update?codeUpdate='.$codeUpdate.'';
                       
            $data = array(
                                 'codeUpdate' => $codeUpdate,
                                 'email' => $email,
                                 'lastupdate' => $update
                                   );
           
            $this->email->from('endangkosasih29@gmail.com','Endang Kosasih');
            $this->email->to($email);
            $this->email->subject('Lost Password');
            $this->email->message($body);
           
            $this->email->send();
           
            $this->db->where('email',$email);
           
            $this->db->update('login',$data);
        }
        else{
            echo 'Email not valid';
        }
       
       
    }
}
?>

3. Finis ,, Please cek !!


Copilot - Membuat Aplikasi Camera Detection menggunakan flutter

  Langkah-langkah Persiapkan Lingkungan Flutter : Pastikan Flutter sudah terinstal di sistem Anda. Jika belum, Anda bisa mengikuti panduan i...