有时在处理POST时缺少textarea值


Sometimes missing textarea value when processing POST

我遇到了一个textarea post值没有得到处理的问题。问题是,间歇性地,我错过了一些值textarea 27和30。这似乎不是浏览器的问题,似乎也不是数据长度的问题。

这是html: 的格式
  <div id="surveycontainer">
      <form method="POST" action="blog/questions" name="exitform">
      <input id="pnum" type="hidden" name="pagenum" value="3"/>
      <div class="qsection">
        <p> 
          27.  Suppose that a friend from another nation comes to see you and doesn’t know about the U.S. economy. How would you <span style="font-style:italic">describe the economy</span> to your friend?  Please actually write the words you would say as specifically as possible.
        </p>
        <textarea id="mlq1" name="27" cols="50" rows="5"></textarea>
      </div>
      <div class="qsection">
        <p> 
          28. What is your opinion about the future of the U.S. economy? Do you think that over the next few months the U.S. economy will improve, become worse, or stay the same?
        </p>
          <input type="radio" name="28" value="-2"><span class="radiotext">-2 (Greatly worse)</span><br/>
          <input type="radio" name="28" value="-1"><span class="radiotext">-1 (Worse)</span> <br/>
          <input type="radio" name="28"  value="0"><span class="radiotext">0 (Stay the same)</span> <br/>
          <input type="radio" name="28" value="1"><span class="radiotext">1 (Better)</span> <br/>
          <input type="radio" name="28" value="2"><span class="radiotext">2 (Much better)</span>
      </div>
      <div class="qsection">
        <p> 
          29. What are the reasons for your prediction? Explain or list them.
        </p>
        <textarea id="mlq2" name="29" cols="50" rows="5"></textarea>
      </div>
      <div class="qsection">
        <p> 
          30. What do you suggest as a solution to improve the U.S. economy?
        </p>
        <textarea id="mlq3" name="30" cols="50" rows="5"></textarea>
      </div>

这里是处理php:

private function processAnswers($pid) 
  {
    date_default_timezone_set('America/Chicago');
    $created = date("Y-m-d H:i:s");
    foreach($_POST as $key=>$value) {
      if ($key == "pagenum")
        continue;
      // echo "$key: $value 'n";
      $sql = "insert into default_answers (participant_id, answer_id, answer_value, created) values (" . $pid . ",'" . htmlspecialchars($key) . "','" . htmlspecialchars($value) . "', '" . $created . "')"; 
      // echo $sql;
      $this->db->query($sql);
    }   
  }

是调用它的代码:

if (isset($_POST['pagenum'])) {
  $pagenum = $this->input->post('pagenum');
  $this->processAnswers($pid);
}

谢谢

谢谢Mock Daear,就这样。mysql_real_escape_string (htmlspecialchars函数)。