以PHP订单形式计算总计

时间:2019-04-09 22:54:06

标签: php totals

我已经创建了一个订单和php处理程序。我真的是php新手。仅使这种形式起作用就是挑战之一。我已经成功地做到了这一点,但现在想对表格进行更大的应用。可以在https://multistrandfilm.com/orderus.html处找到该表格。我想总计订购的每张海报的数量,然后乘以每张30.00美元的固定海报费用。我认识到我需要插入一个函数,该函数a)将总计数量,然后b)创建一个变量,该变量是将总计与我的小计相乘30的结果。我非常确定,一旦完成该过程,我将能够弄清楚如何应用用户输入的税率(将税率从金额更改为本地税率)以及添加运费总额。我完全不知道该在何处以及如何使用该功能。

我的表格


<form id="order_form" name="order_form" method="post" action="mail.php">
<fieldset>
  <legend>Realtor</legend>
  <p>Quantity &#40;minimum order &#45; 5 Posters&#41;</p>
<br>
  <p><input name="poster1" type="text" form="order_form" size="4">X Poster 1</p>
  <p><input name="poster2" type="text" form="order_form" size="4">X Poster 2</p>
  <p><input name="poster3" type="text" form="order_form" size="4">X Poster 3</p>
<br>
  <p><input name="ttlqty" type="text" required="required" form="order_form" size="4">TOTAL NUMBER OF POSTERS</p>
  <p>X &#36;30.00 &#40;US&#41;</p>
  <p>= &#36;<input name="subtotal" type="text" required="required" form="order_form" size="8">&#40;US&#41; SUB TOTAL</p>
<br>
  <p>= &#36;<input name="taxes" type="text" required="required" form="order_form" size="8">&#40;US&#41;  LOCAL TAXES</p>
<br>
  <p>PLUS &#36;40.00 &#40;US&#41; SHIPPING</p><p>= &#36;<input name="total" type="text" required="required" form="order_form" size="8">&#40;US&#41; ORDER TOTAL</p>
</fieldset>
</form>

我的处理程序

<?php

$poster1 = $_POST['poster1'];
$poster2 = $_POST['poster2'];
$poster3 = $_POST['poster3'];
$ttlqty = $_POST['ttlqty'];
$subtotal = $_POST['subtotal'];
$taxes = $_POST['taxes'];
$total = $_POST['total'];
$message = $_POST['message'];

$email_from = 'multistrandfilm.com';
$email_subject = 'Contact Form Submission';

$email_body =   "Qty Poster 1: $poster1.\n".
                "Qty Poster 2: $poster2.\n".
                "Qty Poster 3: $poster3.\n".
                "Quantity Ordered: $ttlqty.\n".
                "SubTotal: $subtotal. \n".
                "Taxes: $taxes. \n".
                "Total: $total. \n".
                "Message: $message. \n";

//$to = "quantumcadworx@gmail.com";
$to = "multii@shaw.ca";

$headers = "From: $email_from \r\n";
$headers = "Reply-To: $email \r\n";

mail ($to, $email_subject, $email_body, $headers) or die("Error!");
header("Location: order.html");

echo "Thank You!" . " -" . "<a href='index.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>

如果有任何问题,我将做更多工作并发布结果。谢谢大家。

0 个答案:

没有答案