title: PHP Post Working with Fields
body: <p>I have a very simple form:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;form method="post" action=""&gt;
  &lt;label&gt;Filter By Zip Code:
  &lt;input maxlength="5" name="zipcode" size="6" type="text" /&gt;&lt;/label&gt;
  &lt;label&gt;Filter By Products:
   &lt;select name="products"&gt;
    &lt;option value=""&gt;Select Product&lt;/option&gt;
    &lt;option value="jewelry"&gt;Jewelry&lt;/option&gt;
    &lt;option value="homedecor"&gt;Home Decor&lt;/option&gt;
    &lt;option value="kitchen"&gt;Kitchen&lt;/option&gt;
  &lt;/select&gt; &lt;/label&gt;
      &lt;label&gt;Filter By Materials:
   &lt;select name="materials"&gt;
    &lt;option value=""&gt;Select Material&lt;/option&gt;
    &lt;option value="abs"&gt;ABS&lt;/option&gt;
    &lt;option value="gold"&gt;Gold&lt;/option&gt;
    &lt;option value="silver"&gt;Silver&lt;/option&gt;
  &lt;/select&gt; &lt;/label&gt;
  &lt;br&gt;
  &lt;input name="submit" type="submit" value="Submit" /&gt;
  &lt;input name="clear" type="submit" value="Clear" /&gt;
  &lt;/form&gt;
  &lt;?php
  if (!isset($_POST['submit'])){
          echo "Nothing Selected";
  }
  elseif(isset($_POST['zipcode']) &amp;&amp; ($_POST['zipcode'] != "")) {
  $zip = $_POST['zipcode'];
          echo "Zip data " . $zip;
  }
  
  elseif(isset($_POST['products'])  &amp;&amp; ($_POST['products'] != "")) {
  $products = $_POST['products'];
          echo "Products data " . $products;
  }
  elseif(isset($_POST['materials'])   &amp;&amp; ($_POST['materials'] != "")) {
  $materials = $_POST['materials'];
          echo "Materials data " . $materials;
  }
  ?&gt;
  </code></pre>
  
  <p>When I am posting data It will only take the value of the first item selected.</p>
  
  <p>I have tried breaking up the if ... elseif and doing some really redundant statements.</p>
  
  <p>ie:</p>
  
  <pre><code>elseif(isset($_POST['materials']) &amp;&amp; ($_POST['materials'] != "") || ($_POST['products'])  &amp;&amp; ($_POST['products'] != "") || $_POST['zipcode'])  &amp;&amp; ($_POST['zipcode'] != "")) {
  </code></pre>
  
  <p>That seems really to complicated and i cannot believe there is not an easier way.</p>
  
  <p>I have tried using a switch ... case however get the same results.</p>
  
  <p>What im looking for is what if two filters are selected?</p>
  
  <p>What if all three are selected?</p>
  
  <p>How can I get the data to post out correctly.</p>