我正在尝试执行这个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
if (isset($_POST['submit']))
{
$k=0;
foreach($_POST['languages'] as $language) {
echo $language = htmlentities($language);
echo $title = $_POST['titles'][$k];
$k++;
}
}
?>
答案 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/>";
}
}
?>