2012-07-27 18 views
2

這似乎是一個簡單的回答問題,但我無法弄清楚如何去做,或者甚至是可能的。當我已經有一個使用GET方法?在我的Querystring

我正在構建搜索欄,以便用戶可以搜索網站上的優惠。它使用POST方法,但它不更新Querystring,並且我希望用戶能夠看到他們搜索的內容,所以我必須使用GET方法。

我的網址設置如下:

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

?rs=offers定義是商品頁面上。沒有?rs=它註冊爲直接訪問index.php文件,並給出錯誤。這就像一個反黑客的事情。

什麼,我想知道的是?rs=offers,所以它讀取這樣的事情後,我如何能夠啓動GET方法:

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> 

回答

6

試試這個:

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

哇,你不知道我現在是多麼愚蠢的感覺-_- ..猜我沒有想到它足夠長的時間!謝謝馬特! – kira423 2012-07-27 17:43:51

+0

@ kira423有時它只需要第二雙眼睛。 – Matt 2012-07-27 17:45:00

+0

添加隱藏是正確的解決方案。 – 2012-07-27 17:45:30

相關問題