title: Echoed textfield unidentified
body: <p>Ok so what happens is I run this code and I get an error at line 68 which is in the second php segment where it grabs the info from the textfield which says:</p>
  
  <pre><code>Notice: Undefined index: fieldno0 in C:\wamp\www\addform.php on line 68
  </code></pre>
  
  <p>Any ideas what is going wrong here? I've been messing with this code and I can't figure out why I can't grab info from the text field.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;?php
      $nof="fieldno";
      $nos="Type";
  
      $servername = "localhost";
      $username = "root";
      $password = "";
      // Create connection
      $conn = new mysqli($servername, $username, $password,"vaccinations");
  
              echo "&lt;form action='addform.php' method='POST'&gt;
  &lt;button type='submit' name='subform'&gt;Submit Form&lt;/button&gt;&lt;br&gt;
  &lt;input type='text' placeholder='Number of fields' name='fieldno'/&gt;&lt;br&gt;
  &lt;input type='text' placeholder='Name of Form' name='form'/&gt;
  &lt;button type='submit' name= 'submit' &gt;Create fields&lt;/button&gt; &lt;br&gt;
  &lt;/form&gt;&lt;br&gt;";
  
  
      $query= $conn-&gt;query("SELECT * FROM element_types");
      $data = array();
      while($rows = $query-&gt;fetch_assoc()){
          $data[] = $rows;
      }
  
  
      if(isset($_POST['submit'])){
           $fields = $_POST['fieldno'];
           $FormName = $_POST['form'];
  
           if($fields &amp;&amp; $FormName){
          $conn-&gt;query("INSERT INTO `vaccinations`.`forms` (`Name`, `author`, `number_of_elements`) VALUES ('$FormName', '5', '$fields');");}
  
          echo "&lt;form action='addform.php' method='POST'&gt;";
  
          for ($i=0; $i&lt;$fields; $i++) {  
  
              echo "&lt;input type='text' placeholder='Enter name of field$i' name='$nof$i'/&gt;";
              echo "$nof$i";
              echo "&lt;select name='$nos$i'&gt;";
              for($x=0;$x&lt;sizeof($data);$x++){
                  echo "&lt;option value=".$data[$x]['id']."&gt;".$data[$x]['name']."&lt;/option&gt;";
                  }
                  echo "&lt;/select&gt;&lt;br&gt;&lt;/form&gt;&lt;br&gt;";
              }           
      }
  
  ?&gt;
  
  &lt;?php
  if((isset($_POST['subform'])) ){
              $fields=$conn-&gt;query("SELECT number_of_elements FROM forms WHERE id IN (SELECT MAX(id) FROM forms)");
  
              while($rows = $fields-&gt;fetch_assoc()){
                      $data[] = $rows;
              }
  
              $data[0] = (int)$data[0];
  
              $fields=$data;
  
              echo("WHADDUP");
  
                  for($y=0;$y&lt;1;$y++){
                      $fieldname = $_POST["$nof$y"];
                      echo $fieldname;
                      //$IorderInForm = ('$y-1');
                      //$selectOption = $_POST["$nos$y"]; 
  
                      //$insert=$conn-&gt;query("INSERT INTO `vaccinations`.`form_elements`
                      // (`form_id`, `field_number_in_form`, `element_type_id`, `field_name`)
                       // VALUES ('$formId', '$IorderInForm', '$selectOption', '$Ifieldname')");
              }
          }   
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>