title: Why isn't PHP reading my $_POST data?
body: <p>I have the following functions in JavaScript:</p>
  
  <pre><code>function AddTextBox(id) {
      if (id == 'national age gender' || id == 'arizona age gender') {
      document.getElementById('text_boxes').innerHTML='Age Group: &lt;input name="age_gender" id="age_group" type="text"&gt; &lt;br /&gt; Male population: &lt;input name="age_gender" id="male" type="text"&gt; Female population: &lt;input name="age_gender" id="female" type="text"&gt; &lt;br /&gt; Male %: &lt;input name="age_gender" id="male_percent" type="text"&gt;  Female %: &lt;input name="age_gender" id="female_percent" type="text"&gt; &lt;br /&gt; Males per 100 females &lt;input name="age_gender" id="m_per_100_f" type="text"&gt; &lt;br /&gt; &lt;button onclick="validateAgeGender(id);"&gt;Add&lt;/button&gt;'; 
  
      }
      if (id == 'national race' || id == 'arizona race') {
      document.getElementById('text_boxes').innerHTML='Category: &lt;input id="cat" type="text"&gt; &lt;br /&gt; White population: &lt;input name="race" id="white" type="text"&gt; White %: &lt;input name="race" id="white percent" type="text"&gt; &lt;br /&gt; Black population: &lt;input name="race" id="black" type="text"&gt; Black %: &lt;input name="race" id="black_percent" type="text"&gt; &lt;br /&gt; Native American population: &lt;input name="race" id="native_american" type="text"&gt; Native American %: &lt;input name="race" id="native_american_percent" type="text"&gt; &lt;br /&gt; Asian: &lt;input name="race" id="asian" type="text"&gt; Asian %: &lt;input name="race" id="asian_percent" type="text"&gt; &lt;br /&gt; Pacific Islander: &lt;input name="race" id="pacific_islander" type="text"&gt; Pacific Islander %: &lt;input name="race" id="pacific_islander_percent" type="text"&gt; &lt;br /&gt; Other: &lt;input name="race" id="other" type="text"&gt; Other %: &lt;input name="race" id="other_percent" type="text"&gt; &lt;br /&gt; &lt;button onclick="validateRace(id);"&gt;Add&lt;/button&gt;';
  
      }
  
  }
  
  
  
  function validateAgeGender(id) {
      if (id == 'national age gender') {
          var data = $('#age_gender').serialize();
          $.post('/CensusDatabase/database_scripts/NationalAgeGender.php', data);
      }
      if (id == 'arizona age gender') {
          var data = $('#age_gender').serialize();
          $.post('/CensusDatabase/database_scripts/ArizonaAgeGender.php', data);
      }
  }
  </code></pre>
  
  <p>And I have the following PHP code:</p>
  
  <pre><code>if(isset($_POST['age_gender'])) { 
      $formSerialized = $_POST['age_gender'];
      $formData = array();
      parse_str($formSerialized, $formData);
      addRow($formData, $link); 
  }
  
  function addRow($dataArray, $link) {
      $age_group = $dataArray[0];
      $populations = array(intval($dataArray[1]) + intval($dataArray[2]), intval($dataArray[1]), intval($dataArray[2]));
      $percents = array(doubleval($dataArray[3]) + doubleval($dataArray[4]), doubleval($dataArray[3]), doubleval($dataArray[4]));
      $m_per_100_f = doubleval($dataArray[6]);
      $query = "INSERT INTO national_age_gender_demographics (age_group, both_pop, male_pop, female_pop, both_percent, male_percent, female_percent, males_per_100_females)
      VALUES ('$age_group','$populations[0]','$populations[1]','$populations[2]','$percents[0]','$percents[1]','$percents[2]','$m_per_100_f')";
      $result = mysqli_query($link,$query);
  
      if(!$result)  die( "Query: " . $query . "\nError:" . mysql_error() );
  
  }
  </code></pre>
  
  <p>Could anyone tell me why this isn't working?  I would like to be able to add to the table by the user data.</p>