Adding input field to PHP emailer only if it exists, how?
<p>I have a form with inputs for 'name' and 'email'. And another for 'data-1'. The user can click on add button and jQuery will dynamically add a input for 'data-2', 'data-3' etc..as needed.</p>

<p>The form is posted to a PHP emailer script which validates fields and places data into a template for mailing.</p>

<p>How can i add inputs 'data-2', 'data-3' etc.. if they are created? And if they are not how can i avoid gaps in my email template? </p>

<p>(is there a way to write it so if the post is received add this and if not do nothing?)</p>

<p>Here is an example of the code i am using:</p>

<pre><code>$name = $_POST['name'];
$email = $_POST['email'];
$data-1 = $_POST['data-1'];
</code></pre>

<p>(do i need to add: $data-2 = $_POST['data-2'] and $data-3....up to a set value of say 10?)</p>

<pre><code>$e_body = "You were contacted by $name today.\r\n\n";
$e_data = "Data Set 1: $data-1.\r\n\n"; 
</code></pre>

<blockquote>
  <p>Here is where i would like to show "Data Set 2/3/4....etc" if they exist</p>
</blockquote>

<pre><code>$e_reply = "You can contact $name via email, $email";

$msg = $e_body . $e_data . $e_reply;

if(mail($address, $e_subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) {
</code></pre>

<p>I hope that is clear and thank you for any help or guidance</p>

<p>thom</p>
