From 692e07f07004c459a12d2d50962621b759733cf9 Mon Sep 17 00:00:00 2001 From: William Date: Thu, 27 Jan 2022 22:08:06 +0100 Subject: [PATCH] Commit --- app/core/Config.php | 3 +-- public/simulator.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/core/Config.php b/app/core/Config.php index 10dcef9..72b7dc4 100644 --- a/app/core/Config.php +++ b/app/core/Config.php @@ -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; } diff --git a/public/simulator.php b/public/simulator.php index f54348e..30ecbfb 100644 --- a/public/simulator.php +++ b/public/simulator.php @@ -1,20 +1,22 @@ 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'); } }