title: Submit Multiple Forms With One Button
body: <p>I am using <code>$_SESSION</code> to dynamically create forms for my web store. These forms hold the custom info for the product that the customer wants. This is the layout:</p>
  
  <p><strong>Page1</strong></p>
  
  <p>Customer fills out form that looks something like this:</p>
  
  <pre><code>&lt;form action="page2" method="post"&gt;
  &lt;input type="text" name="size"&gt;
  &lt;input type="text" name="color"&gt;
  &lt;input type="submit" name="submit" value="Review Order"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Page2</strong></p>
  
  <p>Customer reviews order details and has the option of adding more products. Customer goes back to page1 to order another one. All of the customer's orders will show on page2 in their respective form.</p>
  
  <p>Looks like this:</p>
  
  <pre><code>Size: 1
  Color: blue
  Click Here To Checkout
  
  Size: 2
  Color:green
  Click Here To Checkout
  
  Size:3
  color:red
  Click Here To Checkout
  </code></pre>
  
  <p>What I want is one button that will add ALL orders to the PayPal cart. Sure they can add every order individually by clicking on <code>Click Here To Checkout</code>, but then they will have to go through a big loop to add multiple products.</p>
  
  <p>I want the customer to be able to add as many products as possible and then click one button that adds all of the orders to the shopping cart.</p>
  
  <p><strong>This is what I tried but it obviously didn't work</strong>:</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function(){
  $('#clickAll').on('click', function() {
      $('input[type="submit"]').trigger('click');
      });
      });
      &lt;/script&gt;
  
      &lt;form action="" method="post"&gt;
      &lt;input type="text" name="name"&gt;
      &lt;input type="submit" name="submit" value="submit"&gt;
      &lt;/form&gt;
  
      &lt;form action="" method="post"&gt;
      &lt;input type="text" name="name"&gt;
      &lt;input type="submit" name="submit" value="submit"&gt;
      &lt;/form&gt;
  
      &lt;form action="" method="post"&gt;
      &lt;input type="text" name="name"&gt;
      &lt;input type="submit" name="submit" value="submit"&gt;
      &lt;/form&gt;
  
      &lt;button id="clickAll"&gt;Submit All&lt;/button&gt;
  </code></pre>
  
  <p><strong>Here is the php script that generates the dynamic forms using <code>$_SESSION</code></strong>:</p>
  
  <pre><code>&lt;?php
  
  if(isset($_POST['submit'])) :
  
  $test = array(
      'size' =&gt; $_POST['size'],
      'color' =&gt; $_POST['color'],
      'submit' =&gt; $_POST['submit']
  );
  
  $_SESSION['testing'][] = $test;
  
  endif;
  
  
  if(isset($_SESSION['testing'])) : 
  
  foreach($_SESSION['testing'] as $sav) {
  
  ?&gt;
  
  &lt;form action="paypal.com/..." method="post"&gt;
  &lt;input type="text" name="size" value="&lt;?php echo $sav['size']; ?&gt;"&gt;
  &lt;input type="text" name="color" value="&lt;?php echo $sav['color']; ?&gt;"&gt;
  &lt;input type="submit" name="submit" value="Click Here to Checkout"&gt;
  &lt;/form&gt;
  
  &lt;?php } endif; ?&gt;
  </code></pre>
  
  <p><strong>So the question is, how can I submit all of the forms with ONE button?</strong></p>