我有一个表单,它使用$_GET重定向到原始表单页面以显示任何错误。但表单本身就位于页面下方。两者的正确使用方式是什么?
我尝试了www.abc.com/index.php?error=missing_input&#review
是的,它肯定对我有用:
<?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片段锚的工作方式有错误的想法。
试试这个简单的代码,如果你有任何问题,请回来找我。
请参阅此链接:http://www.ietf.org/rfc/rfc3986.txt用于rfc3986规格。
foo://example.com:8042/over/there?name=ferret#nose
'_/ '______________/'_________/ '_________/ '__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ ' / '
urn:example:animal:ferret:nose
试着删除"missing_input"后面的"&",看看这是否有效。