首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >表单提交时未收到电子邮件

表单提交时未收到电子邮件
EN

Stack Overflow用户
提问于 2019-04-04 14:10:11
回答 1查看 19关注 0票数 0

我在this website中为购物车页面设计了一封电子邮件。当单击“结帐”时,什么也不会发生。相反,它会显示一个具有不同页眉的空页。

PHP:

代码语言:javascript
复制
<?php
  $subject = "An order has been placed on your website";

if (isset($_POST['button '])) {
  $firstName = $_POST['first-name'];
  $lastName = $_POST['last-name'];
  $mailFrom = $_POST['email'];
  $address = $_POST['address'];
  $productName = $_POST['product-name'];
  $quantity = $_POST['quantity'];
  $phone = $_POST['tel'];

  $mailTo = "admin@onlineooty.co.in";
  $headers = "From: ".$mailFrom;
  $txt = "you have recieved a mail from ".$firstName.".\n\n"."whose address is  : ".$address.".\n\n"."the product name is: ".$productName."\n\n"."the phone number is: ".$phone;

  mail($mailTo, $subject, $txt, $headers );
  header("Location: cart.php?mailsend");
}
?>

我的表单:

代码语言:javascript
复制
<form class="emailForm" action="email.php" method="post">
  <div class="input-checkbox">
    <div class="caption">
      <div class="form-group">
        <input class="input" type="text" name="first-name" placeholder="First Name">
      </div>
      <div class="form-group">
        <input class="input" type="text" name="last-name" placeholder="Last Name">
      </div>
      <div class="form-group">
        <input class="input" type="email" name="email" placeholder="Email">
      </div>
      <div class="form-group">
        <input class="input" type="text" name="address" placeholder="Address">
      </div>
      <div class="form-group">
        <input class="input" type="text" name="product-name" placeholder=" product required">
      </div>
      <div class="form-group">
        <input class="input" type="number" name="quantity" placeholder="quantity in kgs" max="10">
      </div>
      <div class="form-group">
        <input class="input" type="text" name="pin-code" placeholder="Pin Code">
      </div>
      <div class="form-group">
        <input class="input" type="tel" name="tel" placeholder="phone">
      </div>
    </div>
  </div>
  </div>
  <div class="payment-method">
  <span>Kindly proceed with the payment to get order confirmation <font color="red">*No refund provided after order confirmation*</font></span>
  <div class="input-radio">
    <label for="payment-2">
    <span>We do accept payments only on Google Pay as of now.
    </span>
    Google Pay
    </label>
    <div class="caption">
      <p>We do accept payments on <font color = "blue">GPay
        </font>, you can pay us on this number <strong>123456789
        </strong>.
      </p>
    </div>
  </div>
  <button class="submit-button" type="submit" name="button">Checkout
  </button>
</form>

EN

回答 1

Stack Overflow用户

发布于 2019-04-04 14:20:37

删除空格,您的代码应该如下所示:

代码语言:javascript
复制
<?php
  $subject = "An order has been placed on your website";

if (isset($_POST['button'])){
  $firstName = $_POST['first-name'];
  $lastName = $_POST['last-name'];
  $mailFrom = $_POST['email'];
  $address = $_POST['address'];
  $productName = $_POST['product-name'];
  $quantity = $_POST['quantity'];
  $phone = $_POST['tel'];

  $mailTo = "admin@onlineooty.co.in";
  $headers = "From: ".$mailFrom;
  $txt = "you have recieved a mail from ".$firstName.".\n\n"."whose address is  : ".$address.".\n\n"."the product name is: ".$productName."\n\n"."the phone number is: ".$phone;

  mail($mailTo, $subject, $txt, $headers );
  header("Location: cart.php?mailsend");

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55508977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档