Php 发送额外的$u POST数据?
我使用表单将一些数据发送到welcome.php文件:Php 发送额外的$u POST数据?,php,Php,我使用表单将一些数据发送到welcome.php文件: <form action="welcome.php" method="post"> Name: <input type="text" name="txt" /> <input type="submit" /> </form> 姓名: 但是,是否可以发送其他变量而不仅仅是表单元素值?假设我也想将数字100发送到welcome.php。如果我理解正确: <input type=
<form action="welcome.php" method="post">
Name: <input type="text" name="txt" />
<input type="submit" />
</form>
姓名:
但是,是否可以发送其他变量而不仅仅是表单元素值?假设我也想将数字100发送到welcome.php。如果我理解正确:
<input type="hidden" name="myNumber" value="100" />
对吗?如果我理解正确:
<input type="hidden" name="myNumber" value="100" />
对吗?您可以将其硬编码到您的操作中:
<form action="welcome.php?number=100" method="post">
您可以将其硬编码到您的操作中:
<form action="welcome.php?number=100" method="post">
这应该可以:
<form action="welcome.php?number=100" method="post"/>
或者使用隐藏的表单输入
<input type="hidden" name="number" value="100" />
这应该可以:
<form action="welcome.php?number=100" method="post"/>
或者使用隐藏的表单输入
<input type="hidden" name="number" value="100" />
您可能会使用隐藏的输入:
<form action="welcome.php" method="post">
<input type="hidden" name="myNumber" value="100" />
Name: <input type="text" name="txt" />
<input type="submit" />
</form>
姓名:
这将把myNumber$\u POST值发送到welcome.php
修改如下操作:welcome.php?myNumber=100
意味着除了表单中的POST变量之外,还发送了GET变量
注意:理论上可以同时使用这两种方法,但我认为这只会将$\u POST值放入$\u请求对象中。在依赖该行为之前,您应该确认这一点。您可能会使用隐藏输入:
<form action="welcome.php" method="post">
<input type="hidden" name="myNumber" value="100" />
Name: <input type="text" name="txt" />
<input type="submit" />
</form>
姓名:
这将把myNumber$\u POST值发送到welcome.php
修改如下操作:welcome.php?myNumber=100
意味着除了表单中的POST变量之外,还发送了GET变量
注意:理论上可以同时使用这两种方法,但我认为这只会将$\u POST值放入$\u请求对象中。在依赖该行为之前,您应该确认这一点。您可以使用html隐藏字段或在会话或cookie变量中存储所需的值您可以使用html隐藏字段或在会话或cookie变量中存储所需的值其他隐藏字段或表单元素,您可以使用
AJAX
发送其他内容把变量放到帖子里
您可以在其中传递url和新变量,而不是表单字段
谢谢。其他隐藏字段或表单元素您可以使用
AJAX
将其他变量发送到帖子中
您可以在其中传递url和新变量,而不是表单字段
谢谢。但请注意它将在$\u-GET中,而不是$\u-POST中,但请注意它将在$\u-GET中,而不是$\u-POST中