Заполненные поля формы PHP - PullRequest
0 голосов
/ 23 ноября 2018

к сожалению, я не могу исправить эту форму, если поля пусты, не следует отправлять электронное письмо

    <?php 
        $to = "info@alpafin.it"; 
        $subject = "Richiesta WEB da WEBFIN"; 
        $body = "Contenuto del modulo:\n\n"; 
        $body .= "Nome: " . trim(stripslashes($_POST["1"])) . "\n"; 
        $body .= "Cognome: " . trim(stripslashes($_POST["5"])) . "\n"; 
        $body .= "Telefono: " . trim(stripslashes($_POST["2"])) . "\n"; 
        $body .= "Email: " . trim(stripslashes($_POST["6"])) . "\n"; 
        $body .= "Provincia: " . trim(stripslashes($_POST["3"])) . "\n"; 
        $body .= "Professione: " . trim(stripslashes($_POST["7"])) . "\n"; 
        $body .= "Importo: " . trim(stripslashes($_POST["4"])) . "\n"; 
        $body .= "Note: " . trim(stripslashes($_POST['8'])) . "\n"; 


        if (!$body || !$cognome || !$Telefono || !$Email !$Provincia || 
        !$Professione || !$Importo || !$Note) {
        echo 'Tutti i campi del modulo sono obbligatori!';    
        }

        ?>

1 Ответ

0 голосов
/ 23 ноября 2018

В вашем коде у вас нет переменных $ cogname, $ telefono, $ email ....

Yo должен объявить, что переменные

$name = trim(stripslashes($_POST["1"]));
$cognome = trim(stripslashes($_POST["5"]));
$Telefono = trim(stripslashes($_POST["2"]));
$Email = trim(stripslashes($_POST["6"]));
$Provincia = trim(stripslashes($_POST["3"]));
$Professione = trim(stripslashes($_POST["7"]));
$Importo = trim(stripslashes($_POST["4"]));
$Note = trim(stripslashes($_POST["8"]));

это код для объявления.

И тогда вы можете написать.

if (!$name || !$cognome || !$Telefono || !$Email || !$Provincia ||  !$Professione || !$Importo || !$Note) {
    echo 'Tutti i campi del modulo sono obbligatori!';    
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...