[英]PHP - Variable inside <form action=“ ”> attribute as part of url for get method
[英]Using get method on form, part of action url doesnt show up when submitted
我有一个奇怪的问题,我有以下表单/php 表单处理程序:
<form id="search" method="get" action="page.php?pg=xxxxxx">
提交时,在 url 中我得到 domain.com/page.pgp?action=xxxx....(更多在这里获取参数)。 如何将 pg=xxxx 正确传递到操作 url 中? 我尝试抛出 & 符号 (page.php?pg=xxxxxx&) 但这似乎也不起作用。
您错误地传递了“xxxxxx”的 pg 值。 这些值应该在表单内的输入标签中传递,例如:
<form id="search" method="get" action="page.php>
<input type="hidden" name="pg" value="xxxxxx">
<input name="submit" value="Submit">
</form>
前面的代码创建了一个带有名为“提交”按钮的表单,当您按下它时,它会将您带到您的页面 action.php,并在 url 中包含您想要的查询字符串:
希望有帮助! :)
改为向表单添加隐藏输入:
<input type="hidden" name="pg" value="xxxxxx" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.