Php引导联系人表单不起作用,未发布电子邮件/数据

Php引导联系人表单不起作用,未发布电子邮件/数据,php,email,contact-form,Php,Email,Contact Form,我在引导中有一个表单,它在一个modal中。当我点击“提交” 似乎什么都没有发生 我已经检查了输入错误和其他错误的代码,我的php代码似乎没有问题,但每次我填写表单并点击提交按钮时,页面都会重新加载,但电子邮件/数据不会发布 以下是完整的php代码: <?php if(isset($_POST['Submit'])){ $to = 'Support@example.com'; // this is your Email address $from = $_POST['faq

我在引导中有一个表单,它在一个modal中。当我点击“提交” 似乎什么都没有发生

我已经检查了输入错误和其他错误的代码,我的php代码似乎没有问题,但每次我填写表单并点击提交按钮时,页面都会重新加载,但电子邮件/数据不会发布

以下是完整的php代码:

<?php
if(isset($_POST['Submit'])){
    $to = 'Support@example.com'; // this is your Email address
    $from = $_POST['faq-contact-email'];// this is the sender's Email address
    $first_name = $_POST['faq-contact-firstname'];
    $last_name = $_POST['faq-contact-lastname'];
    $division = $_POST['faq-contact-subject'];
    $subject = $_POST['contact-subject'];
    $themessage = $_POST['faq-contact-msg'];

    $message = 'Support mail from : '.$first_name.' '.$last_name.'<br/>
    To : '.$division.' Division<br/>
    <hr/>
    '.$themessage.'';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: ".$from."\r\n"."X-Mailer: php";
    mail($to,$subject,$message,$headers);


    echo "Support message Sent. Thank you " . $first_name . ", we will contact you shortly.";
} 

?>
<div class="content">
<div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">
                                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#faq4" href="#faq4_q1"><i class="fa fa-envelope-o"></i> Contact Support</a>
                                        </h3>
                                    </div>
                                    <div id="faq4_q1" class="panel-collapse collapse in">
                                        <div class="panel-body">
                                            <form method="post" action="" class="form-horizontal push-10-t" >
                                                <div class="form-group">
                                                    <div class="col-xs-6 col-sm-4">
                                                        <div class="form-material form-material-primary">
                                                            <input class="form-control" type="text" id="faq-contact-firstname" name="faq-contact-firstname" placeholder="Enter your firstname..">
                                                            <label for="faq-contact-firstname">Firstname</label>
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-6 col-sm-4">
                                                        <div class="form-material form-material-primary">
                                                            <input class="form-control" type="text" id="faq-contact-lastname" name="faq-contact-lastname" placeholder="Enter your lastname..">
                                                            <label for="faq-contact-lastname">Lastname</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="col-sm-8">
                                                        <div class="form-material form-material-primary input-group">
                                                            <input class="form-control" type="email" id="faq-contact-email" name="faq-contact-email" placeholder="Enter your email..">
                                                            <label for="faq-contact-email">Email</label>
                                                            <span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <div class="col-sm-4">
                                                        <div class="form-material form-material-primary">
                                                            <select class="form-control" id="faq-contact-subject" name="faq-contact-subject" size="1">
                                                                <option value="1">Tech Support</option>
                                                                <option value="2">Billing</option>

                                                            </select>
                                                            <label for="faq-contact-subject">Where?</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-xs-6 col-sm-4">                                                        
                                                <div class="form-material form-material-primary">
                                                <input class="form-control" type="text" id="contact-subject" name="contact-subject" placeholder="Enter your subject..">
                                                <label for="contact-subject">Subject</label>                                                        
                                                </div>                                                    
                                                </div>
                                                <div class="form-group">
                                                    <div class="col-xs-12">
                                                        <div class="form-material form-material-primary">
                                                            <textarea class="form-control" id="faq-contact-msg" name="faq-contact-msg" rows="7" placeholder="Enter your message.."></textarea>
                                                            <label for="faq-contact-msg">Message</label>
                                                        </div>
                                                        <div class="help-block text-right">Feel free to use common tags: &lt;blockquote&gt;, &lt;strong&gt;, &lt;em&gt;</div>
                                                    </div>
                                                </div>
                                                <div class="form-group remove-margin-b">
                                                    <div class="col-xs-12">
                                                        <button class="btn btn-sm btn-primary" name="submit" type="submit"><i class="fa fa-send push-5-r"></i> Send Message</button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
</div>
检查第一行

if(isset($_POST['Submit']))     
您已经编写了“提交”(大写字母S),其中按钮的名称为“提交”。那就去吧

if(isset($_POST['submit']))

好的,我回答我的评论

if(isset($_POST['Submit'])) 
将提交更改为提交。你也可以使用

if(isset($_POST))

相反

if(isset($\u POST['Submit'])将Submit更改为Submit,您还可以使用if(isset($\u POST))omg!你是个救命恩人,我发现自己更不谨慎了,非常感谢你,你应该让@duatis把它作为一个答案贴出来,并在它解决了你的问题时将它标记为已验证谢谢你@sam我就是这么做的是的,我没看到