title: html form selector security vulnerability
body: <p>if i have this simple form selector below:</p>
  
  <pre><code>&lt;form id="myform" class="form" role="form" accept-charset="utf-8" method="post" action="/mypage.php"&gt;
      &lt;select id="gender" name="gender"&gt;
       &lt;option selected="" value=""&gt;&lt;/option&gt;
       &lt;option value="man"&gt;man&lt;/option&gt;
       &lt;option value="women"&gt;women&lt;/option&gt;
      &lt;/select&gt;
      &lt;button type="submit" name="insert"&gt; Send &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and this little php code to retrieve data:</p>
  
  <pre><code>    if (isset($_POST['insert'])) {
          if(!isset($_POST['gender']) || strlen($_POST['gender'])&lt;3)
          {
                          header('location:'.$_SERVER['PHP_SELF'].'?error');
                          exit;
          }
  
          $gender = ($_POST['gender']);
       ...
      // INSERT INTO DATABASE
      }
  </code></pre>
  
  <p>and now someone with Firebug modify the option value from "man" to "vulnerability" and click submit this new value will be insert into my database and not the previous one. </p>
  
  <p>My question is: how can i prevent this with php language ?</p>
  
  <p>thanks.</p>