0

我已经制作了这样的邮件表格

<?php

//session_start();


$Total = $_POST['Total'];
$room = $_POST['room'];
$letter = $_POST['letter'];
$Name = $_POST['name'];
$Email = $_POST['email'];
$Address = $_POST['address'];
$Message = $_POST['message'];
$body = "Message sent from CARBONYZED Quotation System | www.CARBONYZED.co.uk ".     "\r\n".
        "// Number of $room = Sel". $letter. " \r\n".
        "// Quote Total = ". $Total. " \r\n".                           
        "// Name = ". $Name. " \r\n".
        "// Email = ". $Email. " \r\n".
        "// Address = ". $Address. " \r\n".
        "// Message = ". $Message. " \r\n".

$subject = "**CONTACT FORM** - From CARBONYZED's Web Server";

      $to = "AffordableCleaners@carbonyzed.co.uk";
        $headers = 'AffordableCleaners@carbonyzed.co.uk' . "\r\n" .
      'Reply-To: AffordableCleaners@carbonyzed.co.uk' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
      if (mail($to, $Email, $body, $headers)) {
    echo("<p>Message successfully sent!</p>  Click here to go <a     href='http://www.affordablecleaners.co.uk'>back</a>");

    } else {
      echo("<p>Message delivery failed...</p>");
    }
       ?>

这很好,除了我需要添加更多功能。在上一页,我有一些盒子,我将在这里发布

<tr>
<td align="left">Stairs</td>
<td align="center" style="text-align: left">
<select name="SelA">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<input type="hidden" name="TotA" onFocus="this.blur();" />
<br></td>
<td width="120" align="center" style="text-align: left">
<select name="SelAA">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<input type="hidden" name="TotAA" onFocus="this.blur();" />
<br></td>
<td width="116" align="center" style="text-align: left">
<select name="SelUA">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<input type="hidden" name="TotUA" onFocus="this.blur();" />
<br></td>


</tr>

你能帮我做两件事,首先拉出楼梯以发送邮件内容(例如楼梯),还有3个值,每个下拉列表中每个的内容......

此外,我们可能会添加一些具有相似数据但不完全相同的所有数据。基本上,楼梯格式的名称文本值总是随机的,但 SelA 和 SelUA 总是在变化。基本上,我们需要它循环并提取这 4 位信息(或 8、12、16 ......

希望某人的疯狂大脑可以提供帮助

问候

亨利

4

2 回答 2

2

提交之前的上一页中的每个表单选项(无论是 POST 还是 GET)都将作为其名称包含在下一页中。就像 PHP 顶部的语句一样,您可以获取框的值:

$SelA= $_POST['SelA'];
$SelAA= $_POST['SelAA'];
$SelUA= $_POST['SelUA'];

然后你可以像你已经拥有的那样在正文中使用这些值:

$body = "Message sent from CARBONYZED Quotation System | www.CARBONYZED.co.uk ".     "\r\n".
        "// Number of $room = Sel". $letter. " \r\n".
        "// Quote Total = ". $Total. " \r\n".                           
        "// Name = ". $Name. " \r\n".
        "// Email = ". $Email. " \r\n".
        "// Address = ". $Address. " \r\n".
        "// Message = ". $Message. " \r\n".
        "// SelA= ". $SelA. " \r\n".
        "// SelAA= ". $SelAA. " \r\n".
        "// SelUA= ". $SelUA. " \r\n".

那是你要找的吗?

于 2012-11-16T01:41:23.500 回答
0

修改表单页面以将输入字段放入数组中:

 <select name="Sel[A]">  ...
 <select name="Sel[AA]">  ...
 <select name="Sel[XA]">  ...    

然后用循环附加那些:

 foreach ($_POST["Sel"] as $key => $value) {

      $email_body .= "// Stairs? $Sel $key = $value \r\n";
 }

是的,这是将变量与字符串连接起来的简便方法。

于 2012-11-16T12:59:15.537 回答