diff --git a/app/class/DatabaseHandler.php b/app/class/DatabaseHandler.php deleted file mode 100644 index dbbda55..0000000 --- a/app/class/DatabaseHandler.php +++ /dev/null @@ -1,23 +0,0 @@ - true, - ]; - try { - return new PDO($dsn, $user, $pass, $options); - } catch (PDOException $e) { - throw new PDOException($e->getMessage(), (int)$e->getCode()); - } - } -} \ No newline at end of file diff --git a/app/class/Template.php b/app/class/Template.php deleted file mode 100644 index 913d6e3..0000000 --- a/app/class/Template.php +++ /dev/null @@ -1,24 +0,0 @@ - 1)) { - $url = htmlspecialchars($url . '/'); - } - - - //FUUUUUCKKK - echo($_SERVER['DOCUMENT_ROOT'] . ' ' . __DIR__); - die(); - return($url.$path); - } - - public function render($name): void - { - require(__DIR__ . '/../template/' . $name . '.php'); - } -} \ No newline at end of file diff --git a/app/common.php b/app/common.php deleted file mode 100644 index 62b6aa6..0000000 --- a/app/common.php +++ /dev/null @@ -1,9 +0,0 @@ -dbh = $this->connectWithMySQL(); + } catch (PDOException $e) { + throw new PDOException($e->getMessage(), (int)$e->getCode()); + } + } + + private function connectWithMySQL(): object + { + $dsn = "mysql:host=$this->host;dbname=$this->db;charset=$this->charset"; + $options = [ + PDO::ATTR_PERSISTENT => true, + ]; + return new PDO($dsn, $this->user, $this->pass, $options); + } +} \ No newline at end of file diff --git a/app/core/Session.php b/app/core/Session.php new file mode 100644 index 0000000..d3351a4 --- /dev/null +++ b/app/core/Session.php @@ -0,0 +1,14 @@ +Hello world +

This is a message from the view

+

\ No newline at end of file diff --git a/app/template/footer.php b/app/view/template/footer.php similarity index 100% rename from app/template/footer.php rename to app/view/template/footer.php diff --git a/app/template/header.php b/app/view/template/header.php similarity index 97% rename from app/template/header.php rename to app/view/template/header.php index e86d03c..66ff18d 100644 --- a/app/template/header.php +++ b/app/view/template/header.php @@ -4,7 +4,7 @@ - <?=htmlspecialchars($this->params["title"]);?> – Stafett for livet + <?=htmlspecialchars($title);?> – Stafett for livet diff --git a/public/example.php b/public/example.php deleted file mode 100644 index 2ab89ac..0000000 --- a/public/example.php +++ /dev/null @@ -1,15 +0,0 @@ -render("header"); -?> - -

Eksempel side

-

Dette er en eksempel side

- -render("footer"); -?> \ No newline at end of file diff --git a/public/index.php b/public/index.php index f34af34..cac92ce 100644 --- a/public/index.php +++ b/public/index.php @@ -1,13 +1,16 @@ render("header"); -?> +// Instantiate a new controller +$contr = new Controller; -

Forsida!

-

Vi planlegger for Kreftforeningens Stafett for livet Kristiansand i juni 2021 og håper du blir med.

-

Stafettene i 2021 tilpasses nasjonale og lokale smittevernsråd, og det vil være lokale variasjoner i hvordan stafettene gjennomføres. Men målet er likt: Vi skal hedre fighterne, vise vår støtte, minnes de vi har mistet, gi håp og feire livet.

+// Grab the model +$model = $contr->model('Index'); -render("footer"); -?> \ No newline at end of file +// Perform database task with model +$username = $model->getUsername(); + +// Display view with retrieved data +$contr->view('index', [ + "data" => $username +]); \ No newline at end of file diff --git a/public/login.php b/public/login.php deleted file mode 100644 index c61f294..0000000 --- a/public/login.php +++ /dev/null @@ -1,25 +0,0 @@ -render("header"); -?> - -

Logg inn

-

Fyll ut legitimasjonen din for å logge inn.

- -
- -
- -
- -
- -
-
- -
- -render("footer"); -?> \ No newline at end of file diff --git a/public/logout.php b/public/logout.php deleted file mode 100644 index f196f4e..0000000 --- a/public/logout.php +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/public/subdir/index.php b/public/subdir/index.php deleted file mode 100644 index 532b273..0000000 --- a/public/subdir/index.php +++ /dev/null @@ -1,15 +0,0 @@ -render("header"); -?> - -

Eksempel side

-

Dette er en eksempel side

- -render("footer"); -?> \ No newline at end of file