This commit is contained in:
William 2022-01-27 22:08:06 +01:00
parent f4ef0b648e
commit 692e07f070
2 changed files with 10 additions and 9 deletions

View File

@ -9,8 +9,7 @@ class Config
{
if (!file_exists($path))
{
echo("Could not find $path");
throw new Exception("Could not find $path");
throw new Exception("Could not find configuration file: $path");
}
$this->config = require $path;
}

View File

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