我有一个大问题:当有人选择多个产品时,例如他选择了 3 个产品,它会进入购物车。当他发送订单(结帐)时,我只看到邮件中的第一个产品,而不是 3。
这是因为我在function.js中已经说过:
function fillInForm(){
NumberOrdered = 0;
NumberOrdered = readCookies("NumberOrdered");
for (i = 1; i <= NumberOrdered; i++){
NewOrder = "Order" + i;
thisCookie = "";
thisCookie = readCookies(NewOrder);;
fields = new Array();
fields = thisCookie.split("|");
document.write("<input type=hidden name=\"Product ID " + i + "\" value=\"" + fields[0] + "\">");
document.write("<input type=hidden name=\"Brand " + i + "\" value=\"" + fields[1] + "\">");
document.write("<input type=hidden name=\"Model " + i + "\" value=\"" + fields[2] + "\">");
document.write("<input type=hidden name=\"Price " + i + "\" value=\"" + fields[3] + "\">");
document.write("<input type=hidden name=\"Amount products " + i + "\" value=\"" + fields[4] + "\">");
document.write("<input type=hidden name=\"Total cost " + i + "\" value=\"" + fields[3] * fields[4] + "\">");
document.write("<input type=hidden name=\" " + "\" value=\"" + "\">");
}
}
当我使用 var_dump($_GET); 它向我展示了一切,所以它向我展示的三种产品都有类似的东西
["Brand_1"]=>
["Brand_2"]=>
["Brand_3"]=>
在发送信息的 mail.php 中,我有:
$brand = $_GET["Brand_1"]; (<<WITH 1, one)
因为
$brand = $_GET["Brand_i"]; (<<WITH i) does not work.
但理论上我需要
$brand = $_GET["Brand_i"] (<<WITH i)to get all the products............
我怎样才能解决这个问题?
邮件.php
$productid = $_GET["Product_ID_1"];
$brand = $_GET["Brand_1"];
$model = $_GET["Model_1"];
$price = $_GET["Price_1"];
$amount = $_GET["Amount_products_1"];
$totalcost = $_GET["Total_cost_1"];
$message .= 'Your order information: ' . '<br />';
$message .= 'Product ID: ' . $productid . "<br />" .
'Brand: '. $brand . "<br />" .
'Model: ' . $model . "<br />" .
'Price per item: ' . $price . "<br />" .
'Amount of item: ' . $amount . "<br />" .
'Total cost: ' . $totalcost . "<br />" .
'Order date and time: ' . $date;
$message .= '</body></html>';