<?php

require_once('../config/config.php');
require_once("../foo/functions.php");
dbconnect();
session_start();

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

	if (admin_attempt($_POST['username'], $_POST['password'])) {
		insert_alast($_SERVER['REMOTE_ADDR'], $_POST['username']);
		log_info($_SERVER['REMOTE_ADDR'], $_POST['username'], $_POST['username'], 'Admin Successfully Signed in');
		redirect('dashboard.php');
	}
	else {
		redirect('index.php?error=' . urlencode('Wrong Username or Password'));
	}
}

?>