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

class Login extends CI_Controller {

	public function __construct()
	{
		parent::__construct();

		$this->data['title'] = "Login | Online Examination";
	}

	
	public function index()
	{
		$username = $this->input->post('login_username');
		$password = $this->input->post('login_password');

		
			if($this->auth->is_valid_user($username,$password)) 
			{
				$this->auth->authorize_user($username);
				redirect(base_url('dashboard'));
			} else {
				if($username != '' || $password != '') {
					set_alert('error','Invalid Username or Password. Please enter correct Username and Password.');
				}
			}

		$this->load->view('login',$this->data);
	}

	public function logout()
	{
		$this->auth->unauthorize_user();
	}
}
