php M or F (male or female)
<p>I know there are more elegant ways to set up an html form to take the input of male or female; however, I am learning, and I was just wondering if this is also possible:</p>

<pre><code>//Incorporate two checks
 if (empty($_POST['sex'])==FALSE &amp;&amp; sanityCheck($_POST['sex'], 'string', 1)==TRUE)
      {
      // if the checks are ok for  sex we assign sex  to a variable
      $sex = $_POST['sex'];
       }
      else
      {
      // if all is not well we echo an error message
      echo 'Please enter a valid Gender';
      // and exit the script
      exit();
      }
</code></pre>

<p>If so, how would I check this with regex?
Whether the user typed M or F.</p>

<p>I am thinking:</p>

<pre><code>function checksex($sexcheck)
{
//Some regex here to check the sex?
  return preg_match('               ', $sexcheck);
}
</code></pre>

<p>And then call checksex as a third check added to the if conditional, like this:</p>

<pre><code>if (empty($_POST['sex'])==FALSE &amp;&amp; sanityCheck($_POST['sex'], 'string', 1) != FALSE &amp;&amp; checksex($_POST['sex'], 1) ==TRUE)
{
...
}
</code></pre>
