<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ps_login extends CI_Controller{
	
	function __construct(){
		parent::__construct();
	}	
	public function index($error = NULL){
        $data['error']=$error;
		$this->load->view('login/form_login',$data);
	}
    public function process(){
		$this->load->model('m_login');
		$result = $this->m_login->validate();
		if(! $result){
            $error = '<div id="alert" class="alert alert-danger alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>
                    Username atau Password Salah!
                  </div>';
            $this->index($error);
		}else{
			redirect('index.php');
		}		
	}
    public function logout(){
        $this->session->sess_destroy();
        redirect('ps_login');
    }
}
?>