php 如何通过表单上的提交按钮传递参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13492699/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I pass a parameter with submit button on form
提问by DrNutsu
I want to create the from that can change product data in mySQL made by PHP.
and I have the key column that auto increment and specify each product.
When i click to edit product link .it will pass the key values that i get from each product
and link to editPage.php
我想创建可以更改由 PHP 制作的 mySQL 中的产品数据的 from。
我有自动递增并指定每个产品的关键列。当我点击编辑产品链接时,它会传递我从每个产品获得的键值并链接到 editPage.php
$Key = $data['Key'];
<a href=\"editPage.php?Key=".$Key."\">edit</a>
in editPage.php i get the key values from previous page and i want pass thisvalues to next page with submit form button.I attach Key values in action link.
在editPage.php 中,我从上一页获取键值,我想通过提交表单按钮将此值传递到下一页。我在操作链接中附加键值。
<?$Key = $_GET["Key"];?>
<form id="form2" name="form1" method="post" action="editWeb.php?Key=".$Key." \">
It don't work, Can I pass Key values with another ways. Tell me if you want more information Thanks!!:))
它不起作用,我可以用其他方式传递键值吗?如果您需要更多信息,请告诉我谢谢!!:))
回答by xdazz
You need to echo the value.
您需要回显该值。
<form id="form2" name="form1" method="post" action="editWeb.php?Key=<? echo $Key ?>"/>
You could also use a hidden input:
您还可以使用隐藏输入:
<form id="form2" name="form1" method="post" action="editWeb.php"/>
<input type="hidden" name="Key" value="<? echo $Key ?>" />
回答by Raab
you need to create a hiddeninput field and place that value in it. and then submit the form
您需要创建一个hidden输入字段并将该值放入其中。然后提交表格
<input type="hidden" id="Key" name="Key" value="<?=$Key ?>">
回答by Ankur Saxena
<form id="" name="form" method="get" action="page.php"/>
<name="" input type="hidden" value="">
<input type="submit" value="">
</form>
GET->show hidden value on required page url.generally we use GET to pass values, it depend upon your requirement.
GET->在所需页面url上显示隐藏值。一般我们使用GET来传递值,这取决于您的要求。

