基本 php 邮件问题:空白变量

Basic php mail issue: blank variables

我遇到了一个奇怪的问题:同一个脚本在我建立的不同网站上有效,但在我当前的网站上无效。 php 脚本引用 html 页面(提交表单),我只想将其发送到电子邮件。这是 HTML 代码:

<form class="form-horizontal" action="invio_mail.php">

    <div class="form-group">
        <label for="indirizzo">Indirizzo attivazione</label>
        <input id="indirizzo" name="indirizzo" type="text" class="form-control" placeholder="Via Roma, 15" required autofocus>
    </div>

    <div class="form-group">
        <label for="modem">Tipo di modem</label>
            <select id="modem" name="modem" class="form-control">
            <option>Indoor</option>
            <option>Outdoor</option>
            </select>
    </div>
    ....
<input name="submit" class="btn btn-lg btn-primary btn-block" type="submit" value="Invia">

这是脚本:

    <?php
$mailto = 'myemail@gmail.com'; 
$subject = 'Form';

$error_message = 'Wooops! Something goes wrong.';
$success_message = '<strong><em>SENT!</em></strong>';

$indirizzo = $_POST['indirizzo']; 
$modem = $_POST['modem'];
$consegna = $_POST['consegna'];
$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$dob = $_POST['dob'];
$paese = $_POST['paese'];
$citta = $_POST['citta'];
$codice_fiscale = $_POST['codice_fiscale'];
$cellulare = $_POST['cellulare'];
$documento = $_POST['documento'];
$scadenza_doc = $_POST['scadenza_doc'];
$rilascio_doc = $_POST['rilascio_doc'];
$email = $_POST['email'];
$note = $_POST['note'];

$message = "The following variables has been registered: $indirizzo $modem $consegna $nome $cognome $dob $paese $citta $codice_fiscale $cellulare $documento $scadenza_doc $rilascio_doc $email $note"; 
$headers = "Da: " . "X-Mailer: PHP/" . phpversion(); 

if (mail($mailto, $subject, $message, $headers)) {
    echo("<br>$success_message <br><br><br>");

;
} else {
    echo($error_message);
}
?>

我收到了邮件,但它不显示我的变量!我不知道为什么,我快疯了。 该消息只有 "The following variables has been registered" 后面什么都没有..我在语法中遗漏了什么吗? 在我的旧网站上运行正常。

谢谢大家的耐心等待。

CodeCaster 的评论是正确的,您的表单正在通过 HTTP GET 方法发出请求 - 如果您没有在表单上指定 method 属性,则这是默认设置。但是您的 PHP 期望在 $_POST 数组中找到变量,只有在使用 HTTP POST 方法发出请求时才会填充该数组。

解决方法很简单——告诉你的表单使用什么方法:

<form class="form-horizontal" action="invio_mail.php" method="POST">