title: PHP Getting a value form a form in POST that has values from a PHP script
body: <p>I created some PHP code to get values from a database and show them as an option in a form I created using HTML. Now I want to be able to select one of those options and then process that in POST. But it gives me an error that my index is undefined when I try to get that value in POST. So I guess my question is, is getting this value possible? If so, how would I accomplish this? </p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;form method="post" action="dayzconfigedit.php"&gt;
  &lt;select name="item1"&gt;;
      &lt;?php
          //Display the Items from the database in a dropdown menu
          $sql = "SELECT item_id FROM `all_items`";
          $result = $conn-&gt;query($sql);
          for($x = 0; $x &lt; $result-&gt;num_rows; $x++) {
              $row = $result-&gt;fetch_assoc();
              echo "&lt;option value=\"{$row["item_id"]}\"&gt;{$row["item_id"]}&lt;/option&gt;";
          }
      ?&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Then I try to get value in POST:</p>
  
  <pre><code>if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
      //Grab Selected Items from Form
      $item1 = "$_POST[item1]";
  }
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p>I skimmed through the post that supposedly answers my question but I still can't solve this issue because I don't know why the index is undefined in the POST array.</p>