title: PHP Form - Text Box or Dropdown List Required
body: <p>I was wondering if someone can help me with this. I have a php contact form with two required fields. Either the user needs to fill out the text field, or select an option from a dropdown list. One or the either needs to be filled out.  Here is what I have:</p>
  
  <pre><code>    // previous requisition number
  if(trim($_REQUEST['prevReqNum']) === '')  {
      $prevReqNumError = '&lt;span class="error"&gt;Please enter your previous requisition number.&lt;/span&gt;';
      $hasError = true;
  } else if (!preg_match("/^([1]-)?[a-z0-9]{6}$/i", trim($_REQUEST['prevReqNum']))) {
      $prevReqNumError = '&lt;span class="error"&gt;You entered an invalid requisition number.&lt;/span&gt;';
      $hasError = true;
  
  // assigned engineer
  } else if(empty($_POST['engineer'])) {
  $engineerError = '&lt;span class="error"&gt;Please select the engineer that you were working with.&lt;/span&gt;';
  $hasError = true; }
  else{
  $engineer = $_POST['engineer'];
  }
  </code></pre>
  
  <p>and here is the HTML:</p>
  
  <pre><code>         &lt;p&gt;&lt;label for="prevReqNum"&gt;*Previous Requisition Number:&amp;nbsp;&lt;/label&gt;&lt;input type="text" size="40" name="prevReqNum" id="prevReqNum" value="&lt;?php if(isset($_POST['prevReqNum'])) echo $_POST['prevReqNum'];?&gt;" placeholder=" eg. 000000" /&gt; &lt;?php if($prevReqNumError != '') { ?&gt;&lt;span class="error"&gt;&lt;?=$prevReqNumError;?&gt;&lt;/span&gt;&lt;?php } ?&gt;
               or &lt;label for="engineer"&gt;Assigned Engineer: &lt;/label&gt;&lt;select name='engineer' id="engineer" size="1"&gt;
                &lt;option value="" selected="selected"&gt;Select&lt;/option&gt;
                &lt;option &lt;?php echo $engineer=='Dexter'?'selected':''; ?&gt; &gt;Dexter&lt;/option&gt;
                &lt;option &lt;?php echo $engineer=='Jake'?'selected':''; ?&gt; &gt;Jake&lt;/option&gt;
                &lt;option &lt;?php echo $engineer=='Mo'?'selected':''; ?&gt; &gt;Mo&lt;/option&gt;
                &lt;option &lt;?php echo $engineer=='Richard'?'selected':''; ?&gt; &gt;Richard&lt;/option&gt;
              &lt;/select&gt; &lt;?php if($engineerError != '') { ?&gt;&lt;span class="error"&gt;&lt;?=$engineerError;?&gt;&lt;/span&gt;&lt;?php } ?&gt;&lt;/p&gt;  
  </code></pre>
  
  <p>So either the user should fill out the requisition number, or choose the engineer they were working with.  I got the requisition number text field working. So when I leave that blank I get an error message. But when I leave the engineer dropdown menu  unselected, I get no error message. Please forgive me I'm not a programmer, so I'm not sure what's wrong here.  Thank you!</p>