<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller
{
	
	public function __construct()
    {
		parent::__construct();
   
        $this->load->library('form_validation');
		$this->load->model('Login_model', 'login', TRUE);
	}

	public function index()
    {
		if(isset($_POST['btnsubmit']))
		{			
			if($this->login->cek_user())
			{
				redirect('home');
			}
			else
			{
				echo"<script>alert('Username atau Password Salah');</script>";
				$this->load->view('login/login_form');
			}
		}
		else 
		{
			$this->load->view('login/login_form');
		}
	}

	public function logout()
	{
        $this->login->logout();
		redirect('login');
	}
}
/* End of file login.php */
/* Location: ./application/controllers/login.php */