title: How to use PHP input array with my dynamic form and PHP emailer script?
body: <p>i have been struggling for a while now trying to finish this, i am new to a lot of this and although i have had some tips i think i am getting myself more lost. So i have stripped the code to a point where it almost works.</p>
  
  <p>DEMO IS HERE: CLOSED</p>
  
  <p>I have a form a customer fills out to submit printer meter readings. Certain printer models have more than 1 reading, up to 3. When the customer clicks 'add printer' jQuery adds content and they select the model from a drop-down and the appropriate number or meter reading inputs appear. They then can click 'add printer' again for multiple printers.</p>
  
  <p>The data is then posted to contact.php where it is validated and then sent by email in a readable format.</p>
  
  <p>The problem i am getting is that i only get the first printer added and not the others. I think i need to use an input array but i don't know how exactly.</p>
  
  <p>I currently get this in the email (only first printer displays):</p>
  
  <blockquote>
    <p>Meter Reading submitted by <b>Craig</b>. Account No. <b>123456</b>, readings are as follows.</p>
    
    <p>Printer Model = <b>Phaser 2010</b>, with Serial No. <b>101010</b>. Mono Reading = <b>1234</b>, Colour Reading = <b>5678</b> , Express Reading = .</p>
    
    <p>Customer <b>Craig</b> email, <b>Craig@craig.com</b></p>
  </blockquote>
  
  <p>--> Notice Express Reading is blank because it was needed. I deally this would not be there at all.</p>
  
  <p>I would like it to come out something like this (when four printers added, two the same model):</p>
  
  <blockquote>
    <p>Meter Reading submitted by <b>Craig</b>. Account No. <b>123456</b>, readings are as follows.</p>
    
    <p>Printer Model = <b>Phaser 2010</b>, with Serial No. <b>101010</b>. Mono Reading = <b>1234</b>, Colour Reading = <b>5678</b></p>
    
    <p>Printer Model = <b>Phaser 2010</b>, with Serial No. <b>202020</b>. Mono Reading = <b>910</b>, Colour Reading = <b>1112</b></p>
    
    <p>Printer Model = <b>ColorQube</b>, with Serial No. <b>303030</b>. Mono Reading = <b>1234</b>, Colour Reading = <b>5678</b>, Express Reading = <b>91011</b> .</p>
    
    <p>Printer Model = <b>WorkCentre 7150</b>, with Serial No. <b>404040</b>. Mono Reading = <b>1234</b></p>
    
    <p>Customer <b>Craig</b> email, <b>Craig@craig.com</b></p>
  </blockquote>
  
  <p>Below is the code for contact.php:</p>
  
  <pre><code>&lt;?php
  
  if(!$_POST) exit;
  
      $name = $_POST['name'];
      $account = $_POST['account'];
      $email = $_POST['email'];
      $printer = $_POST['printer'];
      $serial = $_POST['serial'];
      $mono = $_POST['mono'];
      $colour = $_POST['colour'];
      $express = $_POST['express'];
  
      if(trim($name) == '') {
          echo '&lt;div class="error_message"&gt;Attention! You must enter your name.&lt;/div&gt;';
          exit();
          } else if(trim($email) == '') {
              echo '&lt;div class="error_message"&gt;Attention! Please enter a valid email address.&lt;/div&gt;';
              exit();
          } else if(!isEmail($email)) {
              echo '&lt;div class="error_message"&gt;Attention! You have entered an invalid e-mail address, try again.&lt;/div&gt;';
              exit();
          }
  
      if($error == '') {
  
          if(get_magic_quotes_gpc()) {
              $comments = stripslashes($comments);
          }
  
      // Configuration option.
      //$address = "example@example.net";
      $address = "somebody@email.com";
  
      // Example, $e_subject = '$name . ' has contacted you via Your Website.';
      $e_subject = 'Meter Reading submitted by - ' . $name . '. Account No.' . $account . '.';
  
      // Configuration option.
      $e_body = "Meter Reading submitted by $name. Account No. $account, readings are as follows.\r\n\n";
  
      // THIS NEEDS TO ONLY SHOW COLOUR AND EXPRESS READING IF THAT PRINTER REQUIRES IT - and - REPEAT FOR EACH ADDED PRINTER
      $e_content = "Printer Model = $printer, with Serial No. $serial. Mono Reading = $mono, Colour Reading = $colour , Express Reading = $express.\r\n\n";
  
      $e_reply = "Customer $name email, $email";
  
      $msg = $e_body . $e_content . $e_reply;
  
      if(mail($address, $e_subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) {
  
  
      // Email has sent successfully, echo a success page.
  
      echo "&lt;fieldset&gt;";          
      echo "&lt;div id='success_page'&gt;";
      echo "&lt;h1&gt;Email Sent Successfully.&lt;/h1&gt;";
      echo "&lt;p&gt;Thank you &lt;strong&gt;$name&lt;/strong&gt;, your message has been submitted to us.&lt;/p&gt;";
      echo "&lt;/div&gt;";
      echo "&lt;/fieldset&gt;";
  
      } else {
  
      echo 'ERROR!';
  
      }
  
  }
  
  function isEmail($email) { // Email address verification, do not edit.
  
  return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
  
  }
  ?&gt;
  </code></pre>
  
  <p>I would be so grateful for some help with this. Please NOTE the linked file "<i>jquery.jigowatt.js</i>" as it also uses post.</p>
  
  <p>I someone can help and sorry it is such a big one to explain and show. If you need any more info to help please let me know.</p>
  
  <p>Thom</p>