| | |
| | | $email = $_POST['email'] ?? ''; |
| | | $msg = ''; |
| | | |
| | | /* |
| | | * |
| | | /** |
| | | * Inserisce i dati trasmessi dal form ($email e $number) nella tabella |
| | | * |
| | | */ |
| | | |
| | | function insertDataOnTable(mysqli $mysql, string $email, string $number) { |
| | | function insertDataOnTable(mysqli $mysql, string $email, string $number): bool { |
| | | $esitoInserimento = false; |
| | | $query = "INSERT INTO Contact (email, telefono) VALUES ('$email', '$number');"; |
| | | try { |
| | |
| | | } |
| | | |
| | | |
| | | /* |
| | | * |
| | | * |
| | | /** |
| | | * controlla se ci sono errori sulla digitazione dei dati messi nel form |
| | | * |
| | | * |
| | | */ |
| | | |
| | | function controlloErrori(string $email, string $number, array &$errorMsgs) { |
| | | function controlloErrori(string $email, string $number, array &$errorMsgs): bool { |
| | | if(!is_numeric($number) || strlen($number) != 10) { |
| | | $errorMsgs['number'] = 'Numero di telefono non corretto'; |
| | | }else { |
| | |
| | | return $validazioneOk; |
| | | } |
| | | |
| | | /* |
| | | * |
| | | * |
| | | /** |
| | | * controlla se nelle 24 ore prima non sia stata messa nel campo email la stessa mail per evitarne lo spam |
| | | * |
| | | * |
| | | */ |
| | | function controlloSpamEmail(mysqli $connection, string $email) { |
| | | function controlloSpamEmail(mysqli $connection, 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();"; |
| | | |