通过电子邮件动态创建字段PHP + JQuery

时间:2013-10-02 13:29:49

标签: javascript php jquery

我无法找到一个确切的答案,我自己也不是开发人员,所以它可能是一些简单的我做错了。

我创建了一个表单,可以使用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);

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

1 个答案:

答案 0 :(得分: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>';

然后我认为你应该在表格

上做一个“为每个”的名字