Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Login extends CI_Controller {
  4.  
  5.     private $rule = array(array('field' => 'username',
  6.                                 'label' => 'Username',
  7.                                 'rules' => 'trim|required|min_length[6]',
  8.                                 ),
  9.     array('field' => 'password',
  10.             'label' => 'Password',
  11.             'rules' => 'trim|required|min_length[6]',
  12.             )
  13.  
  14.     );
  15.  
  16.     public function __construct()   {
  17.         parent::__construct();
  18.         $this->load->model('option_m');
  19.         $option = $this->option_m->get_by(array('nama_opsi' => 'store_option'));
  20.         foreach (unserialize($option->value_opsi) as $key => $val){
  21.             $this->data->$key = $val;
  22.         }
  23.         $this->template->use_asset()->set_judul('Form Login')->set_css('login');
  24.  
  25.         $this->data->metadata = $this->template->get_metadata();
  26.         $this->data->judul = $this->template->get_judul();
  27.     }
  28.  
  29.     public function index(){
  30.         $username = $this->input->post('username');
  31.         $password = $this->input->post('password');
  32.  
  33.         $this->load->library('form_validation');
  34.         $this->form_validation->set_rules($this->rule);
  35.         if($this->form_validation->run()){
  36.             $this->autentifikasi->login($username,$password);
  37.             redirect(site_url('admin'));
  38.         }
  39.         $this->_view('login', $this->data);
  40.     }
  41.  
  42.     private function _view($filename,$data){
  43.         $this->load->view('admin/header',$data);
  44.         $this->load->view($filename,$data);
  45.         $this->load->view('admin/footer',$data);
  46.     }
  47.  
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement