在表单上使用get方法,部分操作url在提交时不会显示

时间:2016-04-21 20:24:28

标签: php forms

我有一个奇怪的问题,我有以下表单/ php表单处理程序:

    <form id="search" method="get" action="page.php?pg=xxxxxx">

在提交时,在网址中我得到domain.com/page.pgp?action=xxxx....(more more parameters here)。如何正确地将pg = xxxx传递给动作网址?我试过抛出一个&amp;签名(page.php?pg = xxxxxx&amp;),但这似乎也不起作用。

2 个答案:

答案 0 :(得分:1)

您正在传递&#34; xxxxxx&#34;的pg值不正确。这些值应该在表单内的输入标记中传递,例如:

<form id="search" method="get" action="page.php>
  <input type="hidden" name="pg" value="xxxxxx">
  <input name="submit" value="Submit">
</form>

之前的代码创建了一个带有名为&#34;提交&#34;的按钮的表单,当您按下它时,它会将您带到页面action.php,其中包含您想要的URL中的查询字符串:

  

http://www.foo.com/action.php?pg=xxxxxx

希望有所帮助! :)

答案 1 :(得分:0)

在表单中添加隐藏的输入:

<input type="hidden" name="pg" value="xxxxxx" />