<?php
$app = require '../app/inc.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
if (!isset($_POST['cardnumber']) || empty($_POST['cardnumber']))
$app->session->flash('Kortnummer kan ikke være tom!', 'danger');
} else {
$model = $app->model('Simulator');
if ($model->insert($_POST['cardnumber']))
$app->session->flash("Lag funnet for \"{$_POST['cardnumber']}\"", "success");
$app->session->flash("Opprettet lag for \"{$_POST['cardnumber']}\"");
}
$app->view('template/header', ['title' => 'Simulator']);
$app->view('simulator');
$app->view('template/footer');