<?php

require_once "../../includes/initialize.php";
if ($session->is_logged_in()) {
    redirect_to("index.php");
}
if (isset($_POST['submit'])) {
    // if form submitted
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);
    $found_user = User::authanticate($username, $password);
    if ($found_user) {
        $session->login($found_user);
        redirect_to('index.php');
    } else {
        $message = "Username / Password Combination incorrect.";
    }
} else {
    // form has not been submitted
    $username = "";
    $password = "";
    $message = "";
}
?>
<html>
  <head>
    <title>Photo Gallery</title>
    <link href="../stylesheets/main.css" media="all" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <div id="header">