This article mainly brings you a solution to the problem that the parameters passed behind the action attribute in the form cannot be obtained. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.
is as follows:
$p_id = $_REQUEST['p_id']; echo "<h1>您将更新商品编号为<span>$p_id</span>的商品信息 <a href='listproduct.php'>查看所有</a></h1> <form action='updateproduct.do.php?p_id=$p_id' method='get'> 商品名称:<input type='text' name='p_name' value='".$result_name2["name"]."'>商品名称小于10个字<br><br> 商品价格:<input type='text' name='p_price' value='".$result_price2["price"]."'>价格大于0且小于99999.99(保留两位小数)<br><br> 图片:<input type='text' name='p_pic' value='".$result_pic2["pic"]."'>请输入图片src<br><br> 生产日期:<input type='text' name='p_date' value='".$result_onShelfDate2["onShelfDate"]."'>格式:yyyy-mm-dd<br><br> 详细信息:<input type='text' name='p_detail' value='".$result_detail2["detail"]."'>详细信息请保持在50字以内<br><br> <button>提交</button> </form>"; ?>
As shown in the above code, I want to submit it by clicking the button While jumping to updateproduct.do.php, pass the $p_id obtained on this page to the next page through the url value. But every time after clicking the button, there is only in the address bar “updateproduct.do.php?p_name=11&p_price=22&p_pic=33&p_date=44&p_detail=55”
##What about p_id It can't be passed on. After struggling for a long time, the reason is actually very simple. (The following is my personal understanding, but the problem is solved) Under method=get, the form only receives the form element "name" attribute and the corresponding "value". Want to write it yourself in the action? Pass the value in the form, the value of method must be =post, that is, the second line in the code is changed to:<form action='updateproduct.do.php?p_id=$p_id' method='post'>
JS function passing parameters by value
php reference definition and reference passing parameter example usage detailed explanation
Detailed explanation of basic syntax of php function and usage examples of passing parameters
The above is the detailed content of The parameters passed after the action attribute in the form cannot be obtained.. For more information, please follow other related articles on the PHP Chinese website!