html-php表单代码没有执行

时间:2013-12-28 08:39:05

标签: php html forms

我正在尝试执行这个html表单代码,php脚本没有正确执行。你能指出问题吗?

<form action="form.php" method="post">

<p>
  <input type="text" name="titles[]" /><br />
  <textarea name="languages[]" ></textarea><br />
</p>

<p>
  <input type="text" name="titles[]" /><br />
  <textarea name="languages[]" ></textarea><br />
</p>

php脚本

<?php

if (isset($_POST['submit']))
{
  $k=0;
  foreach($_POST['languages'] as $language) {
    echo $language = htmlentities($language);
    echo $title    = $_POST['titles'][$k];
    $k++;
  }
}
?>

1 个答案:

答案 0 :(得分:0)

HTML

<form action="form.php" method="post">
<p>
  <input type="text" name="titles[]" /><br />
  <textarea name="languages[]" ></textarea><br />
</p>

<p>
  <input type="text" name="titles[]" /><br />
  <textarea name="languages[]" ></textarea><br />
</p>

<input type="submit" name="submit" id="submit" value="Submit">

</form>

PHP

<?php

if (isset($_POST['submit']))
{

   foreach($_POST['languages'] as $key => $language) {
       echo $language = htmlentities($language);
       echo " -- ";
       echo $title    = $_POST['titles'][$key];
   echo "<br/>";

   }
}
?>