将 URL 参数添加到表单 PHP HTML
将 url get 参数放在表单操作中是否可以或正确?
Is it okay or correct to put a url get parameter in a form action?
<form method='get' action='index.php?do=search'>
<input name='_search' type='text' value='What are you looking for?'>
<button type='submit'> Search </button>
</form>
当我提交表单时,URL 更改为:
When I submit the form the URL is changed to:
index.php?_search=What are you looking for? (I've stripped %20)
我更喜欢阅读网址
index.php?do=search&_search=What are you looking for?
最好在表单中添加一个隐藏字段
Would it be best to add a hidden field into the form
<input type='hidden' name='do' value='search' />
推荐答案
在我看来,您应该将它们添加为隐藏字段.如果您可以通过隐藏表单字段来传递参数,那么尝试传递参数是没有意义的
In my opinion you should add them as hidden fields. There is no point to try to pass params if you can do it via hidden form field
使用:
<input type='hidden' name='do' value='search' />
相关文章