From 8e493d574a3a54f23041f47617545b19e6193573 Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Tue, 11 Jun 2024 11:18:23 +0200 Subject: [PATCH] fix foreach --- views/Fiat/contact.mvc.php | 8 +++----- src/App/Models/Contact.php | 4 ---- src/App/Controllers/fiat.php | 4 +++- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/App/Controllers/fiat.php b/src/App/Controllers/fiat.php index b107467..c352617 100644 --- a/src/App/Controllers/fiat.php +++ b/src/App/Controllers/fiat.php @@ -30,6 +30,7 @@ } public function contact() { + if($_SERVER['REQUEST_METHOD'] === 'POST') { $data = [ "email" => $this->request->post["email"], @@ -38,9 +39,10 @@ $this->model->insert($data); } - + $errors = $this->model->getErrors(); return $this->view("Fiat/contact.mvc.php", [ + "errors" => $errors ]); } diff --git a/src/App/Models/Contact.php b/src/App/Models/Contact.php index 5af3053..ec7888f 100644 --- a/src/App/Models/Contact.php +++ b/src/App/Models/Contact.php @@ -34,10 +34,6 @@ if($this->controlloSpamEmail($data["email"])) { $this->addError("spam", "non puoi mandare la stessa mail, aspetta un pò di tempo"); } - - - - var_dump($this->getErrors()); } diff --git a/views/Fiat/contact.mvc.php b/views/Fiat/contact.mvc.php index 8d54766..da0cb04 100644 --- a/views/Fiat/contact.mvc.php +++ b/views/Fiat/contact.mvc.php @@ -14,11 +14,9 @@ <input type="text" name="telefono" placeholder="inserisci il numero"> <br> <button type="submit">clicca qui</button> </form> - {$formMsg} - {foreach from=$error item=errore key=campo} - {$errore} - <br> - {/foreach} + {% foreach ($errors as $error): %} + <h4>{{error}}</h4> + {% endforeach; %} </main> {% include "../views/Fiat/footer.mvc.php" %} -- Gitblit v1.8.0