在没有jQuery/Ajax的同一HTML/PHP页面中提交,是iFrame的唯一选项


Submit in the same HTML/PHP page without jQuery/Ajax, is iFrame is the only option?

我想在提交的同一页中输出<form>,我用html <iframe>完成了,除了jQuery和Ajax,还有其他选择吗?

提前谢谢。

如果form标记的"action"属性为空,它将被提交到同一页面。然后,您可以检查表单是否已提交,并相应地处理页面。

也许类似于:

<?php
 if($_POST['submitted']){
  echo "I have been submitted";
echo "<br/>";
  echo $_POST['text_input'];
}
?>
<form method="post">
<input type="text" name="text_input">
<input type="submit" value="Submit" name="submitted">
</form>