了解自引用表单


Understanding Self Referencing forms

我正在努力学习Self Referencing Forms。我读到php脚本中嵌入的html表单是一个自引用表单。我仍然无法选择这个概念。我在php代码中看到的几乎所有形式都是用html构建的。自引用表单是否比嵌入php脚本的html表单更具体?

你的意思可能是这样的:

<?php
if (count($_POST)) {
echo 'You have submitted the string: '.$_POST['string'];
}
?>
<form action="" method="post">
<input type="text" name="string">
<button type="submit">Submit!</button>
</form>

空的action属性会导致浏览器将其提交到与加载的URL相同的URL。我们通过count($_POST)检查表格是否已提交,并采取相应行动。