title: How to obtain PHP variable array values?
body: <p>Here i am asking the user to enter in candidates names from the amount of textboxes they have specified in the page before this one. In my second page <strong>Ballot.php</strong> I am trying to write what was entered in these created text boxes to a text file but the called variable is always empty. Any ideas? Thanks</p>
  
  <p>The values contained in $_POST["raceList"] and $_POST["canList"] are entered in values.</p>
  
  <pre><code>&lt;form action="CreateBallot.php" method="post"&gt;
  How many races within ballot?
  &lt;input type="number" name="raceList" id="raceList"&gt;
          &lt;br&gt;
          How many candidates in each race?
          &lt;input type="number" name="canList" id="canList"&gt;
          &lt;br&gt;
  </code></pre>
  
  <p><strong>Page 1(CreateBallot.php):</strong></p>
  
  <pre><code>&lt;form action="Ballot.php" method="post"&gt;
        &lt;?php   
  
                 for($x = 1; $x &lt;= $_POST["raceList"]; $x++){
  
                 echo ("&lt;h1&gt;Race #" . $x . "&lt;/h1&gt;&lt;br&gt;");
                 echo ("Please fill in candidates:&lt;br&gt;");
                for($y = 1; $y &lt;= $_POST['canList']; $y++){
                    $textboxes = array("&lt;input type='text' name='txtbox' id='txtbox' value=''&gt;");
                      echo $textboxes[0];
                }
                 }
  
  
           ?&gt;
  &lt;p&gt;&lt;a class="btn btn-info"  href="Election Commissioner.php"  role="button" &gt;Go Back &amp;raquo;&lt;/a&gt;
  &lt;a class="btn btn-info" id="startRace" href="Ballot.php" name="startRace" role="button" onclick="butclik();"&gt;Finish Ballot &amp;raquo;&lt;/a&gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Page2(Ballot.php)</strong></p>
  
  <pre><code>Candidates:&lt;br&gt;
            &lt;?php 
              $race1 = fopen("race1.txt" , "a") or die("Unable to open file!");
                  $name1 = $_POST[$textboxes[0]];
                  fwrite($race1,$name1 . "\r\n");
  
              fclose($race1);
  
          ?&gt;
  </code></pre>