在Boostrap弹出模式窗口中联系表单

时间:2015-09-18 03:10:46

标签: php html twitter-bootstrap bootstrap-modal contact-form

我正在使用bootstrap来打开一个模态表单。

我真的无法弄清楚发生了什么。此代码适用于其他项目(http://phpform.webitwebsites.co.nz/newtest/)并发送邮件没问题。但是,如果我将它复制到我的网站,就像我的提交按钮没有响应,它不会加载启动quote.php文件。 这是一个不起作用的实时版本 http://phpform.webitwebsites.co.nz/test/

我的HTML:

<button href="#freeQuote" role="button" data-toggle="modal" type="button" class="btn btn-primary btn-lg outline" style="font-size:16px;">Free Quote</button>
</center>
<div class="modal fade" id="freeQuote">
<div class="modal-dialog">
<div class="modal-content">
    <div class="modal-header">
        <button class="close" data-dismiss="modal">&times;</button>
            <h3 class="modal-title">FREE Quote</h3>

    </div>
    <!-- close modal-header -->
    <div class="modal-body">
            <h4>Send us a description </h4>
        <hr>
        <form name="contact" method="post" action="quote.php">
            <label for="name">Your Name</label>
            <br>
            <input class="col-md-10" type="text" name="name" class="input-xlarge">
            <br>
            <br>
            <label for="company">Your Company</label>
            <br>
            <input class="col-md-10" type="text" name="company" class="input-xlarge">
            <br>
            <br>
            <label for="email">Your E-mail</label>
            <br>
            <input class="col-md-10" type="email" name="email" class="input-xlarge">
            <br>
            <br>
            <label for="message">Details</label>
            <br>
            <textarea class="col-md-10" name="message" class="input-xlarge"></textarea>
            <br>
            <input class="btn-sm btn-success" type="submit" value="Send!" id="submit">
        </form>
    </div>
    <!-- close modal-body -->

我的PHP

<?php
$myemail = 'example@gmail.com';
if (isset($_POST['name'])) {
    $name = strip_tags($_POST['name']);
    $company = strip_tags ($_POST['company']);
    $email = strip_tags($_POST['email']);
    $message = strip_tags($_POST['message']);
    echo "<span class=\"alert alert-success\" >Your message has been received. Thanks! Here is what you submitted:</span><br><br>";
    echo "<stong>Name:</strong> ".$name."<br>";   
    echo "<strong>Company:</strong> " .$company . "<br>";
    echo "<stong>Email:</strong> ".$email."<br>"; 
    echo "<stong>Message:</strong> ".$message."<br>";

    //generate email and send!
    $to = $myemail;
    $email_subject = "New Quote form submission";
    $email_body = "You have received a new message. ".
    " Here are the details:\n Name: $name \n ".
    "Email: $email\n Message \n $message";
    $headers = "From: $myemail\n";
    $headers .= "Reply-To: $email";
    mail($to,$email_subject,$email_body,$headers);
}
?>

0 个答案:

没有答案