This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/public/login.php
2022-03-30 06:52:18 +00:00

25 lines
686 B
PHP

<?php $app = require '../app/inc.php';
if ($app->user->loggedIn)
{
$app->session->flash('Du er allerede pålogget');
$app->redirect('index.php');
}
$username = (string)filter_input(INPUT_POST, 'username');
$password = (string)filter_input(INPUT_POST, 'password');
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
if ($app->user->login($username, $password))
{
$app->session->flash("Velkommen {$username}!");
$app->redirect('index.php');
}
http_response_code(401);
$app->session->flash('Feil påloggingsinformasjon', 'danger');
}
$app->view('template/header', ["title" => "Logg inn"]);
$app->view('pages/login');
$app->view('template/footer');