我已经拥有了GET方法?在我的查询字符串中

时间:2012-07-27 17:38:36

标签: php forms get

这似乎是一个简单的回答问题,但我无法弄清楚如何做到这一点,或者甚至是否可能。

我正在构建搜索栏,以便用户可以在网站上搜索优惠。它使用POST方法,但它不更新Querystring,我希望用户能够看到他们搜索的内容,所以我必须使用GET方法。

我的网址设置如下:

http://mysitename.com/index.php?rs=offers

?rs=offers定义在商品页面上。如果没有?rs=,它会注册为直接访问index.php文件,并给出错误。这就像一个反黑客的东西。

我想知道的是我如何在GET之后启动?rs=offers方法,所以它的内容如下:

http://mysitename.com/index.php?rs=offers&find=whatisearched

现在它看起来像这样:

http://mysitename.com/index.php?find=whatisearched

这给出了我上面描述的错误。

这也是当前的表单布局,因此您可以查看其中是否存在我可能定义错误的内容。

<form method='get' action='index.php?rs=offers'>
    <table class='offers'>
<tr>
    <th>Search All Offers</th>
</tr>
<tr> 

    <td>

      <input type='text' name='find' maxlength='255' style='width:200px' value='' />

      <input type='submit' value='Search' />

    </td>

  </tr>

</table>
</form>

1 个答案:

答案 0 :(得分:6)

请改为尝试:

<form method='get' action='index.php'>
    <input type='hidden' name='rs' value='offers' />
    .
    .
    .
</form>