在HTML< form>中发布额外的值 [英] POST extra values in an HTML <form>
本文介绍了在HTML< form>中发布额外的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的形式,可以传递<input />
元素的值:
I have a simple form which passes the value of an <input />
element:
<form action="updaterow.php" method="POST">
<input type="text" name="price" />
</form>
如何与<input />
值一起发布额外的值?例如,任意字符串或当前PHP脚本中的变量.
How can I post extra values along with the <input />
value? For example, an arbitrary string, or a variable inside the current PHP script.
我知道使用GET可以做到这一点
I know this is possible with GET:
<form action="updaterow.php?foo=bar" method="GET">
<input type="text" name="price" />
</form>
或:
<form action="updaterow.php?foo=<?=htmlspecialchars($bar)?>" method="GET">
<input type="text" name="price" />
</form>
但是我需要POST.
推荐答案
您可以包含隐藏的表单元素.
You can include a hidden form element.
<input type="hidden" name="foo" value="bar" />
这篇关于在HTML< form>中发布额外的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文