输入无线电不发送数据

时间:2016-07-05 13:58:46

标签: php contact-form

我有一个简单的联系表格,html就是这个部分:

<!-- CONTACT FORM -->

<form id="contact-form" name="contactform" class="row">
    <!-- CONTACT FORM IMPUT -->
    <div id="input_name" class="col-md-12">
        <input type="text" name="name" id="name" class="form-control" placeholder="Il tuo nome"> 
    </div>
    <div id="input_email" class="col-md-12">
        <input type="text" name="email" id="email" class="form-control" placeholder="Email"> 
    </div>
    <div id="input_subject" class="col-md-12">
        <input type="text" name="subject" id="subject" class="form-control" placeholder="Numero di telefono"> 
    </div>
    <div id="input_message" class="col-md-12">
        <textarea class="form-control" name="message" id="message" rows="6" placeholder="Il tuo messaggio..."></textarea>
    </div>   
    <div class="col-md-12 sinistra"><br>Quale servizio ti interessa?<br><br></div>
    <div class="col-md-4 sinistra">
        <input type="radio" name="tipologia" value="standard"> Standard<br>
    </div>
    <div class="col-md-4 sinistra">
        <input type="radio" name="tipologia" value="avanzato"> Avanzato<br>
    </div>
    <div class="col-md-4 sinistra">
        <input type="radio" name="tipologia" value="deluxe"> Deluxe<br>
    </div>
    <div class="col-md-12"><br></div>
    <!-- CONTACT FORM SUBMIT BUTTON -->
    <div id="form_btn" class="col-md-12">                           
        <input type="submit" value="Invia" id="submit" class="btn btn-small btn-blue">                                  
    </div>
    <!-- CONTACT FORM MESSAGE -->
    <div class="col-md-12 contact-form-msg">
        <span class="loading"></span>
    </div>
</form>

使用这个php文件

 <?
     $name  = $_REQUEST["name"];
     $email = $_REQUEST["email"];
     $subject   = $_REQUEST["subject"];
     $msg   = $_POST["msg"];
     $tipologia = $_POST['tipologia'] ;
     $to    = "info@gmail.com"; 
     if (isset($email) && isset($name) && isset($msg) ) {
         $email_subject = "$name ha inviato una richiesta di ordine"; 
         $headers = "MIME-Version: 1.0" . "\r\n";
         $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
         $headers .= "Da: ".$name." <".$email.">\r\n"."Reply-To: ".$email."\r\n" ;
         $msg     = "Da: $name<br/> Email: $email <br/> Telefono: $subject <br/>    
                     Tipologia: $tipologia <br/> Messaggio: $msg";

         $mail =  mail($to, $email_subject, $msg, $headers);
         if($mail)
         {
             echo 'success';
         }
         else
         {
             echo 'failed';
         }
     }
 ?>

但是我的收音机输入有问题,表格有效,但没有将收音机的价值传递给电子邮件,因此电子邮件中没有为表格选择收音机的Tipologia ......可能是什么错误?< / p>

1 个答案:

答案 0 :(得分:2)

如果不暗示POST,

<form>默认为GET方法。

您正在使用两个POST阵列。

所以......使用POST方法和所有POST阵列。

无论哪种方式,一切都必须匹配。

您还应该检查是否设置了单选按钮,或者是否要包含任何其他按钮。