How can I pass a parameter with submit button on f

2019-07-03 14:43发布

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

$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.

<?$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!!:))

标签: php html forms
3条回答
再贱就再见
2楼-- · 2019-07-03 15:31

you need to create a hidden input field and place that value in it. and then submit the form

<input type="hidden" id="Key" name="Key" value="<?=$Key ?>">
查看更多
一纸荒年 Trace。
3楼-- · 2019-07-03 15:33
<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.

查看更多
祖国的老花朵
4楼-- · 2019-07-03 15:37

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 ?>" />
查看更多
登录 后发表回答