php表单不发送提交数据。但是仍然发送电子邮件和处理表格

时间:2014-12-17 06:35:45

标签: php forms contact-form submission

我的网站上有两个表单。一个工作正常,另一个发送电子邮件与email_from:etc但没有捕获任何表单数据。

想知道它可能是什么。如果这有助于调试,我也可以发布与它一起工作的表单。使用堆栈溢出/其他站点非常新手和构建形式。

                                 咖啡                                                                                                                          
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Quantity</label>
                        <div class="col-sm-4">
                          <input type="text" name="quantity" class="form-control" placeholder="Quantity : " required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">Name</label>
                        <div class="col-sm-6">
                          <input type="text" name="name" class="form-control" placeholder="Name : " required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">Email address</label>
                        <div class="col-sm-6">
                          <input type="email" name="email" class="form-control" placeholder="Email address : " required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">Shipping Address</label>
                        <div class="col-sm-6">
                          <textarea class="form-control" name="shipping_address" rows="8" placeholder="Shipping Address : " required></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">Payment Method</label>
                        <div class="col-sm-6">
                          <select class="form-control" required>
                            <option value="Paypal">Paypal</option>
                          </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">Notes</label>
                        <div class="col-sm-6">
                          <textarea class="form-control" name="notes" rows="8" placeholder="Notes : "></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-10">
                            <button type="submit" class="btn btn-black">Order Now</button></a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

这是php

<?php

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

{

 $coffee = ($_POST['coffee']));
 $quantity = ($_POST['quantity']));
 $name = ($_POST['name']));
 $email = ($_POST['email']));
 $shipping_address = ($_POST['shipping_address']));
 $notes = ($_POST['notes'])); 
 }

$email_from ='paradigmcoffee@gmail.com';
$email_subject="New Order Submission";
$email_body ="You have received a new message from user $name.\n".
"Email_address:$email\n".
"Coffee: $coffee\n".
"Quantity: $quantity\n".
"Shipping_Address: $shipping_address\n".
"Notes: $notes\n".

$to ="paradigmcoffee@gmail.com";
$headers = "From: $email \r\n";

mail($to,$email_from,$email_subject,$email_body,$headers);
header("Location: http://www.paradigmcoffee.co/order_thanks.html");
?>

1 个答案:

答案 0 :(得分:0)

根据您提供的内容,您可能无法获取数据的原因是因为您没有发送任何名为submit的内容。尝试命名按钮:

<!-- name="submit" added -->
<button name="submit" type="submit" class="btn btn-black">Order Now</button>

您可以执行此操作或创建隐藏字段:

<input type="hidden" name="submit" value="1" />