2

我有一个表单,它使用 $_GET 重定向到原始表单页面以显示任何错误。但表单本身位于页面下方。两者的正确使用方法是什么?

我试过了www.abc.com/index.php?error=missing_input&#review

4

2 回答 2

3

是的,它肯定对我有用:

<?php

if (!isset($_GET['submitted'])) {
    echo "<form action='#fragment'><input type='text' name='text'><input type='submit' name='submitted' value='Do it'></form>";
} else {
    echo "<div style='height: 800px'>Vertical Padding<br>Your text was: {$_GET['text']}</div><div id='fragment'>This is the fragment</div>";
}

如果它不适合您,我怀疑您正在生成的页面上没有具有参考 ID 的元素,或者您通常对 URL 片段锚的工作方式有错误的想法。

试试这个简单的代码,如果你有任何问题,请回来找我。

于 2012-07-23T17:10:43.760 回答
2

有关rfc3986 规范, 请参阅此链接:http ://www.ietf.org/rfc/rfc3986.txt。

     foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment
      |   _____________________|__
     / \ /                        \
     urn:example:animal:ferret:nose

尝试删除“missing_input”之后的“&”,看看是否有效。

于 2012-07-23T17:09:05.257 回答