Php 表单输入将参数传递到错误的url

Php 表单输入将参数传递到错误的url,php,html,forms,input,Php,Html,Forms,Input,我试图让我的表单将一个参数传递给如下链接: index.php?action=2&parameter=value 相反,它所做的只是像这样传递参数: index.php?parameter=value 这是我的代码: <form class="navbar-form navbar-left" action="index.php?action=2" method="get" name="search"> <div class="form-group">

我试图让我的表单将一个参数传递给如下链接:

index.php?action=2&parameter=value
相反,它所做的只是像这样传递参数:

index.php?parameter=value
这是我的代码:

<form class="navbar-form navbar-left" action="index.php?action=2" method="get" name="search">
  <div class="form-group">
      <input type="text" class="form-control" placeholder="put something here...." name="search" width="100">
  </div>
  <button type="submit" class="btn btn-default">search</button>
</form>

我的表单位于上面的_test.php文件中。

您尝试执行的操作可以通过使用隐藏字段来完成。在表单中添加以下输入字段:

<input type="hidden" name="action" value="<?php echo $_GET['action']; ?>" />

使用
action=“index.php”
然后为
操作添加一个隐藏输入
-
@Fredd:好的,删除了我之前的评论。(这个也会有点自毁)嗨,阿马尔,这正是我要找的。FDL的建议几乎有效,但它没有分配值,因此链接看起来像action=¶meter=value。然而,这一个工作得非常好。谢谢大家!@艾比:很高兴能帮上忙!
<input type="hidden" name="action" value="<?php echo $_GET['action']; ?>" />