<?php
include_once('../helpers/sessions.php');
include_once('../helpers/routes.php');
include_once('../helpers/credentials.php');
if(isset($_POST['login'])){
	$username = $_POST['username'];
	$password = $_POST['password'];
	if(login($username,$password)){
		unset($_SESSION['login_error']);
		$_SESSION['username'] = $username;
		header('Location:'.base_url().'index.php');
	}else{
		$_SESSION['login_error'] = "Invalid Login Details!";
		$referer = $_SERVER['HTTP_REFERER'];
		header('Location:'.$referer);
	}
}
?>