title: trying to select multiple answers in a from by PHP
body: <p>The following code is the HTML from a file that I am trying to out put multiple selections by clicking the submit button:</p>
  
  <pre><code>&lt;form id="eg6b" action="example-6.php" method="post"&gt;
       &lt;p&gt;
      &lt;label for="sport"&gt;Favourite sport: &lt;/label&gt;
      &lt;select id="sport" name="favsport []" size="4" multiple&gt;
          &lt;option value="soccer"&gt;Soccer&lt;/option&gt;
          &lt;option value="cricket"&gt;Cricket&lt;/option&gt;
          &lt;option value="squash"&gt;Squash&lt;/option&gt;
          &lt;option value="golf"&gt;Golf&lt;/option&gt;
          &lt;option value="tennis"&gt;Tennis&lt;/option&gt;
          &lt;option value="basketball"&gt;Basketball&lt;/option&gt;
          &lt;option value="baseball"&gt;Baseball&lt;/option&gt;
      &lt;/select&gt;
  
  
       &lt;input type="submit" value="submit"&gt;&lt;/p&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>The following code is the PHP file to obtain multiple Sports:</p>
  
  <pre><code>&lt;?php
  
        foreach($_POST["favsport"] as $val) {
           echo "&lt;p&gt;You chose $val &lt;/p&gt;";
        }
  
    ?&gt;
  </code></pre>
  
  <p>I just cant find the error. If I run this code it gives me an error that <code>the favsport is undefined and that the argument supplied to the foreach loop is invalid</code>. I have messed around with it alot but now I am just tired.</p>