Monday, March 4, 2013

Register with CI And Send Email

Script Input / Register with Codeigniter :
1. Create class clogin.php in Controller
script :

<?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 add(){
   
        if ($this->input->post('register')){
           
                                   
            $this->mlogin->adduser();
            redirect('index.php/clogin','refresh');
            }
            else {
            echo'Gagal';
       
        }
    }
}
?>

2. Create Model with name mlogin
script :
<?php
class mlogin extends CI_Model {
function adduser(){
       
        $username = $this->input->post('username');
        $password = $this->input->post('password');
        $name = $this->input->post('name');
        $email = $this->input->post('email');
        $status='inactive';
       
                $jml_code = 6;
                $source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                $max = strlen($source)-1;
               
                $code = "";
                mt_srand((double)microtime()*1000000);
                while(strlen($code)<$jml_code)
                $code .= $source{
                    mt_rand(0,$max)
                };

                           
        $data = array(
        'name' => $name,
        'email' => $email,
        'username' => $username,
        'password' => sha1($password),
         'code' => $code,
         'status' => $status
        );
       
        //pengecekan email di database
        $query="SELECT * FROM login WHERE email='$email'";
       
        $cek=$this->db->query($query);
        if($cek->num_rows()>0){
           
            redirect('index.php/cerror','refresh');
           
        }
        else{
            $this->load->library('email');
            $email=$this->input->post('email');
            $name=$this->input->post('name');
           
                           
            $body='Welcome'.' '.$name.',
            Terima Kasih telah mendaftar di website kami, Silahkan klik link di bawah ini untuk aktivasi akun Anda.
            http://festiware.com/endang_ci/index.php/clogin/activation?code='.$code.'';
           
           
            $this->email->from('endangkosasih29@gmail.com','Endang Kosasih');
            $this->email->to($email);
            $this->email->subject('Aktivasi Email ');
            $this->email->message($body);
           
            $this->email->send();
           
            $this->db->insert('login',$data);
       
        }
               
    }
}

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...