From 7bc6e3058c600c716c0d427208b201eecdbd70ca Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Mon, 06 May 2024 11:11:16 +0200
Subject: [PATCH] gestione views utilizzando variabile globale _GET[] (parte 16)

---
 index.php |   30 +++++++++++-------------------
 1 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/index.php b/index.php
index cbca938..98326de 100644
--- a/index.php
+++ b/index.php
@@ -1,21 +1,13 @@
 <?php
-    require "model.php";
-    $model = new Model;
-    $products = $model->getData();
-?>
 
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Products</title>
-</head>
-<body>
-    <h1>Products</h1>
-    <?php foreach ($products as $product): ?>
-        <h2><?= htmlspecialchars($product["name"]) ?></h2>
-        <p><?= htmlspecialchars($product["description"]) ?></p>
-    <?php endforeach; ?>
-</body>
-</html>
\ No newline at end of file
+require "src/controllers/products.php";
+$controller = new Products;
+$action = $_GET["action"];
+
+
+if($action === "index") {
+    $controller->index();
+}elseif($action === "show") {
+    $controller->show();
+}
+    
\ No newline at end of file

--
Gitblit v1.8.0