我设置了一些“订单”页面,允许人们选择要购买的物品。当他们点击“订单”时,它会将他们带到一个页面,该页面允许他们选择每个项目的详细信息 drom 动态填充的下拉列表。这些下拉菜单处于循环中,因此每个项目都有自己的集合。
这就是我的问题开始的地方。如果订单页面上只有一件商品,它可以完美运行。从下拉列表中选择的所有信息都被拉入我的 PHP 脚本,并将其格式化为电子邮件并将订单发送给我。如果订单中的商品超过 1 件,则只会发送页面上的最后一件商品。
这是下拉菜单的代码...
<form name="mediumselect">
<table>
<tr>
<td>
<select name="sel" onchange="selFormat(this);" style="width:200px">
<option value="">-Please select delivery format-</option>
<option value="File">File</option>
<option value="Tape">Tape</option>
<option value="Disc">Disc</option>
</select>
</td>
<td>
<select name="formats" onchange="selRate(this)" style="width:150px">
</select>
</td>
<td>
<select name="framerate" onchange="selColor(this)" style="width:150px">
</select>
</td>
<td>
<select name="color" style="width:150px">
</select>
</td>
</table>
</form>
这是PHP...
<?php
$asset = $_REQUEST['assetname'];
$medium = $_REQUEST['sel'];
$type = $_REQUEST['formats'] ;
$framerate = $_REQUEST['framerate'] ;
$color = $_REQUEST['color'] ;
$body = <<<EOD
Asset Name: $asset
Asset format: $medium
Format Type: $type
Frame Rate/Resolution: $framerate
Codec or Color Subsample: $color
EOD;
$results = <<<EOD
<html>
<head>
<title>sent message</title>
<style type="text/css">
</style>
</head>
<div align="center">One your order is submitted, a confirmation email will be sent to above email with order details.</div>
</div>
</body>
</html>
EOD;
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{
//if "email" is filled out, proceed
//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "Invalid input";
} else {
//send email
global $body;
global $results;
$email = $_REQUEST['email'] ;
mail("~~~@gmail.com", "Subject: INCOMING ORDER", $body, "From: $email" );
echo "$results";
}
} else {//if "email" is not filled out, display the form
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text'><br>
Subject: <input name='subject' type='text'><br>
Message:<br>
<textarea name='message' rows='15' cols='40'>
</textarea><br>
<input type='submit'>
</form>";
}
?>
我还是 PHP 新手,如果有更好的方法来做这件事,我将不胜感激。