title: wordpress form submission and the 404 error page
body: <p>I have the following form on a wordpress template page. I'm getting a 404 error each time i submit the form but I'm not using any of the reserved workpress parameter names in the form.</p>
  
  <pre><code>&lt;?php
  /**
   * Template Name: Registration Template
   */
  if(isset($_POST['form-submitted'])) 
  {
      if(trim($_POST['runner']) === '') {
          $runnerError = 'Please enter runner runner.';
          $hasError = true;
      } else {
          $runner = trim($_POST['runner']);
      }
  
      if(trim($_POST['racenumber']) === '')  {
          $numberError = 'Please enter a race number.';
          $hasError = true;
      } else {
          $racenumber = trim($_POST['racenumber']);
      }
  
      $race = trim($_POST['race']);
      error_log($race.' '.$runner.' '.$racenumber);
      $registrationSubmitted = true;
  }
  get_header();
  echo "&lt;pre&gt;GET "; print_r($_GET); echo "&lt;/pre&gt;";
  echo "&lt;pre&gt;POST "; print_r($_POST); echo "&lt;/pre&gt;";
  ?&gt;
  
  &lt;div id="container"&gt;
  
      &lt;?php 
      if(isset($registrationSubmitted) &amp;&amp; $registrationSubmitted == true) 
      {
          echo '&lt;div class="thanks"&gt;&lt;p&gt;The runner has been registered.&lt;/p&gt;&lt;/div&gt;';
      }
      else
      {
          $races = // magic array
          $selectRaces = '&lt;select name="race" id="race"&gt;';
          foreach($races as $racez)
          {
              $selectRaces .= sprintf('&lt;option value=%d&gt;%s&lt;/option&gt;',$race-&gt;id,$race-&gt;name);
          }
          $selectRaces .= '&lt;/select&gt;';
  
          echo apply_filters('the_content','
              &lt;form action="'.get_permalink().'" id="form" method="POST"&gt;
                  [one_half last="no"]
                  &lt;b&gt;Race Details&lt;/b&gt;&lt;br/&gt;
                  RaceNumber&lt;input type="text" name="racenumber" id="racenumber"/&gt;&lt;br/&gt;
                  Race'.$selectRaces.'&lt;br/&gt;
                  [/one_half]
                  [one_half last="yes"]
                  &lt;b&gt;Runner Details&lt;/b&gt;&lt;br/&gt;
                  ID&lt;input type="text" name="runner" id="runner"/&gt;&lt;br/&gt;
                  Firstname&lt;input type="text" name="first" id="first"/&gt;&lt;br/&gt;
                  Surname&lt;input type="text" name="last" id="last"/&gt;&lt;br/&gt;
                  Gender&lt;input type="text" name="gender" id="gender"/&gt;&lt;br/&gt;
                  DOB&lt;input type="text" name="dob" id="dob"/&gt;&lt;br/&gt;
                  Standard&lt;input type="text" name="standard" id="standard"/&gt;&lt;br/&gt;
                  Company&lt;input type="text" name="company" id="company"/&gt;&lt;br/&gt;
                  [/one_half]
                  &lt;input type="submit" value="Register Runner"/&gt;
                  &lt;input type="hidden" name="form-submitted" id="bhaa-submitted" value="true" /&gt;
              &lt;/form&gt;');
      }
      echo '&lt;/div&gt;';
  ?&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>I've customised my 404 page to dump the $_POST values so i'm sure the parameter values are being submitted.</p>
  
  <pre><code>[racenumber] =&gt; 5
  [race] =&gt; 2596
  [runner] =&gt; 5
  [first] =&gt; 
  [last] =&gt; 
  [gender] =&gt; 
  [dob] =&gt; 
  [standard] =&gt; 
  [company] =&gt; 
  [form-submitted] =&gt; true
  </code></pre>
  
  <p>Can anyone explain my the logic in my 'isset($_POST['form-submitted'])' is not being exercised?</p>
  
  <p>The generated html </p>
  
  <pre><code>&lt;form action="http://localhost/registration/" id="form" method="POST"&gt;
  &lt;div class="one_half"&gt;
                  &lt;b&gt;Race Details&lt;/b&gt;&lt;br&gt;&lt;br&gt;
                  RaceNumber&lt;input name="number" id="number" type="text"&gt;&lt;br&gt;&lt;br&gt;
                  Race&lt;br&gt;
  &lt;select name="race" id="race"&gt;
  &lt;option value="2596" id="2596"&gt;4-Mile-M&lt;/option&gt;
  &lt;option value="2595" id="2595"&gt;2-Mile-W&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>EDIT</p>
  
  <p>I've changed the code where is set the values of the select dropdown to use an incrementing int value rather than using sprintf to map a string value to an int value. When the first element is selected the form submits, if the second option is picked i get a 404!</p>
  
  <pre><code>$races = // magic array
  $selectRaces = '&lt;select name="race" id="race"&gt;';
  $i=0;
  foreach($races as $racez)
  {
      $selectRaces .= sprintf('&lt;option value=%d&gt;%s&lt;/option&gt;',$i++,$race-&gt;name);
  }
  </code></pre>