开发者

Submitting search form but also having query string in PHP (and JS)

开发者 https://www.devze.com 2023-04-12 05:34 出处:网络
I have a page with a search form (with just one field) submitting to another page to perform a search and show results.

I have a page with a search form (with just one field) submitting to another page to perform a search and show results.

Often on other sites whenever I search for something in a form I see my search terms in a query string which is handy for bookmarking/sharing a link with someone.

eg-

 http://grooveshark.com/#/search开发者_如何学编程?q=name+of+band

How is the query string made from a form submission?


Change your form to use the get method instead of post, or add the attribute below if it's not there already.

<form name="test" action="some/page.php" method="get">


The query string is constructed by the user agent by processing the form data. You can read more about it here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号