1

我找不到确切的答案,而且我自己也不是开发人员,所以这可能很简单,我做错了。

我创建了一个表单,它可以使用 jquery 动态添加一组字段并克隆标签,如下所示:

<div class="container"><li id="li_6" >
    <label class="description" for="element_6">Advert Title (Up to 35 characters including spaces) </label>

        <input id="element_6" name="element_6[]" class="element text medium" type="text" maxlength="255" value=""/> 

    </li>       <li id="li_7" >
    <label class="description" for="element_7">Advert Body Text (Up to 70 characters including spaces) </label>

        <textarea id="element_7[]" name="element_7" class="element textarea small"></textarea> 

    </li>       <li id="li_8" >
    <label class="description" for="element_8">Advert Keywords (These are the words or phrases your potential customers will search for. Only 1 per line) </label>

        <textarea id="element_8[]" name="element_8" class="element textarea medium"></textarea> 

    <a href="#" id="add">
Click to Add Another Advert</a> <a href="#" id="remove">| Remove Last Advert</a>
</li>

所有这一切都很好,唯一的问题是当电子邮件功能运行时,我只得到最新添加的字段组,而不是收到的电子邮件中的所有字段:

if($act=="post"){
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: 123Click<support@123click.co.za>' . "\r\n";
$to       = 'support@123click.co.za';
$subject  ='New Adwords Setup';
$message  = "<b><u>Section A: Login</u></b>&nbsp;".'<br>';
$message  = "<b>Login Email:</b>&nbsp;".$_POST["element_1"].'<br>';
$message  = "<b><u>Section B: Settings</u></b>&nbsp;".'<br>';
$message .= "<b>Location:</b>&nbsp;".$_POST["element_9"].'<br>';
$message .= "<b>Daily Budget:</b>&nbsp;".$_POST["element_10"].'<br>';
$message .= "<b>Web Address:</b>&nbsp;".$_POST["element_4"].'<br>';
$message  = "<b><u>Section C: Adverts</u></b>&nbsp;".'<br>';
$message .= "<b>Advert Title:</b>&nbsp;".$_POST["element_6"].'<br>';
$message .= "<b>Advert Body:</b>&nbsp;".$_POST["element_7"].'<br>';
$message .= "<b>Advert Keywords:</b>&nbsp;".$_POST["element_8"].'<br>';

mail($to, $subject, $message, $headers);

我做错了什么,请尽可能简单地解释。谢谢

4

1 回答 1

0

首先要小心 "$message =" 它应该是

$message  = "<b><u>Section A: Login</u></b>&nbsp;".'<br>';
$message .= "<b>Login Email:</b>&nbsp;".$_POST["element_1"].'<br>';
$message .= "<b><u>Section B: Settings</u></b>&nbsp;".'<br>';
$message .= "<b>Location:</b>&nbsp;".$_POST["element_9"].'<br>';
$message .= "<b>Daily Budget:</b>&nbsp;".$_POST["element_10"].'<br>';
$message .= "<b>Web Address:</b>&nbsp;".$_POST["element_4"].'<br>';
$message .= "<b><u>Section C: Adverts</u></b>&nbsp;".'<br>';
$message .= "<b>Advert Title:</b>&nbsp;".$_POST["element_6"].'<br>';
$message .= "<b>Advert Body:</b>&nbsp;".$_POST["element_7"].'<br>';
$message .= "<b>Advert Keywords:</b>&nbsp;".$_POST["element_8"].'<br>';

那么我认为你应该为表格上的每个“名称”

于 2013-10-02T13:43:49.323 回答