From a13080a7484e40a5fb87fa2fe1980856eb60f252 Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Tue, 11 Jun 2024 10:39:41 +0200 Subject: [PATCH] cambio nome model perchè bindato alla tabella del database --- /dev/null | 21 ---------- src/App/Models/Contact.php | 45 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/App/Models/Contact.php b/src/App/Models/Contact.php new file mode 100644 index 0000000..5af3053 --- /dev/null +++ b/src/App/Models/Contact.php @@ -0,0 +1,45 @@ +<?php + namespace App\Models; + + use PDO; + use Framework\Model; + class Contact extends Model { + //protected ?string $table = "product"; + + public function controlloSpamEmail(string $email, ): bool { + $spam = false; + $query = "SELECT email, dtm_richiesta FROM Contact WHERE email = '$email' AND dtm_richiesta BETWEEN DATE_SUB(NOW(), INTERVAL 1 DAY) AND NOW();"; + $connection = $this->database->getConnection(); + + $result = $connection->query($query); + + $rowcount = count($result->fetchAll(PDO::FETCH_ASSOC)); + var_dump($rowcount); + + + if ($rowcount > 0) { + $spam = true; + } + + return $spam; + } + protected function validate(array $data): void { + + if(empty($data["email"])) { + $this->addError("email","email is required"); + } + if(empty($data["telefono"])) { + $this->addError("telefono","cell number is required"); + } + if($this->controlloSpamEmail($data["email"])) { + $this->addError("spam", "non puoi mandare la stessa mail, aspetta un pò di tempo"); + } + + + + var_dump($this->getErrors()); + } + + + + } \ No newline at end of file diff --git a/src/App/Models/FiatModel.php b/src/App/Models/FiatModel.php deleted file mode 100644 index f433f2a..0000000 --- a/src/App/Models/FiatModel.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - namespace App\Models; - - use PDO; - use Framework\Model; - class FiatModel extends Model { - //protected ?string $table = "product"; - - - protected function validate(array $data): void { - - if(empty($data["email"])) { - $this->addError("email","email is required"); - } - if(empty($data["number"])) { - $this->addError("number","cell number is required"); - } - - var_dump($this->getErrors()); - } - } \ No newline at end of file -- Gitblit v1.8.0