我为this website中的购物车页面设计了一封电子邮件。单击结帐时,什么也没有发生。而是显示带有不同标题的空白页。
PHP:
<?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");
}
?>
我的表单:
<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>
答案 0 :(得分:0)
删除空格,您的代码应如下所示:
<?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");
}