title: Echo out values of text-boxes created fia for loop in PHP
body: <p>I have the following form:
  (please note I am aware that there are no validation in my code)</p>
  
  <pre><code>&lt;form name="frmsplitter" method="POST" enctype="multipart/form-data" action = 'step2.php'&gt;
  
          &lt;table&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
  
                      &lt;select style="width: 80%" name="cobbulkamount"&gt;
                          &lt;option&gt;please select a bulk item&lt;/option&gt;
                          &lt;option value= 100&gt;100&lt;/option&gt;
                          &lt;option value= 200&gt;200&lt;/option&gt;
                          &lt;/select&gt;
  
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;label&gt;Select number of items you want the bulk amount to be splited : &lt;/label&gt;&lt;input type="text" name="txtnumberofitems" value="&lt;?php if (isset($_POST['btnsplitItem'])){echo $_POST['txtnumberofitems'];}?&gt;" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
  
                      &lt;td&gt;&lt;input type="submit" value="submit" name="btnsplitItem" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;           
      &lt;/form&gt;`
  </code></pre>
  
  <p>the form submits it goes to the following page :</p>
  
  <pre><code>    &lt;?php
  
      if (!empty($_POST['txtnumberofitems'])) {
          $bulkvalue = 200;
          $numberofitems = $_POST['txtnumberofitems'];
              echo "&lt;form name='frmsplitter'  method='POST' action = 'step3.php'&gt;";     
              echo "amount to be splited &lt;input type='text' name='txtamountof' value =$numberofitems&gt; ";
                  for ($index = 0; $index &lt; $numberofitems; $index++) {           
                      echo  "&lt;table&gt;".  
                      "&lt;tr&gt;
                      &lt;td&gt;|amount: &lt;input type='text' name='txtamount.$index'/&gt;&lt;/td&gt;
                      &lt;td&gt;|Reference 2: &lt;input type='text' name='txtref.$index'/&gt;&lt;/td&gt;
                      &lt;td&gt;|DCIP:&lt;select name='cobdcip'.$index&gt;
                      &lt;option&gt;DR&lt;/option&gt;
                      &lt;option&gt;CR&lt;/option&gt;
                      &lt;/select&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;/table&gt;";
                      }
                          echo "&lt;br&gt;";
                          echo "&lt;input type='submit' name='btnpopulate' /&gt;";
                          echo "&lt;/form&gt;";        
      }       
      ?&gt;`
  </code></pre>
  
  <p>the form submits it goes to the following page :</p>
  
  <pre><code>        if (isset($_POST['btnpopulate'])) {
              $number = (int)$_POST['txtamountof'];
              for ($index = 0; $index &lt; $number; $index++) {
                  if (!empty($_POST['txtamount'.$index])) 
              { 
                      echo 'nooooooooooo';
              }
                  else {                     
                          echo $_POST['txtamount'.$index];
                          echo '&lt;br&gt;';
                  }   
              }
          } `
  </code></pre>
  
  <p>My problem is that I get the Notice: Undefined index: txtamount0 
  and Notice: Undefined index: txtamount1 </p>