Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POST vs GET method for a search form in CMS

I'm a bit stuck with one thing. Just can't make up my mind on whether to use POST or GET method at my search form.

Normally I would use GET method for such a form, so users could bookmark their results they got. But this time, the search form is present in administration area, so results are relevant shortly and there is no need to bookmark results and of course, they aren't public for everyone.

To be more specific, the search feature is meant to be used along with a list of users, so there could be some specific user to be searched. My idea was to use POST method, where the form would be redirected to the same page so I would get a list of users filtered by search string. There was also pagination, so I would add the search string at the and of each pagination link (next page, previous page, first page and last page link) so the search string wouldn't be lost later on (within any session coming after the search like paginating of searched results etc.).

There is no obvious reason to prefer one before another, both can be used. The POST method would be a little bit more hassle, but on the other hand, there are advanced options within the search form (about 5 checkboxes) and I don't like the idea of having meesed up URL bar with way too many values (and I expect users not to use pagination after search session so often, so the values wouldn't get to the address bar so often) if POST method used.

Which one would you prefer for searching in CMS and alike systems?

Thanks everyone!

like image 624
Ondrej Avatar asked Sep 26 '11 19:09

Ondrej


People also ask

What is the difference between the GET and POST methods of a form?

Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data from client to ...

Which is better POST or GET method?

POST request is comparatively more secure because the data is not exposed in the URL bar. Request made through GET method are stored in Browser history. Request made through POST method is not stored in Browser history. GET method request can be saved as bookmark in browser.

Is search a GET or POST?

Search is not necessarily a Post, you're trying to get some data, not modify or insert.


2 Answers

You are getting data, so use GET. POST will create issues with refreshing and going back.

Don't obsess over the beauty of your URIs, they are a tool not a piece of art.

like image 140
Quentin Avatar answered Oct 22 '22 15:10

Quentin


Maybe, I would (mostly) always choose post over get, it's more tidy and refreshing and going back issues with post method are a thing from the past in any major browser, they just ask you if you want to resend the data, don't they?

The MAJOR exception would be bookmark of a dynamic webpage (like movieweb.com/movies.php?movie=the_three_mosqueteers, for example), but still, if that's not the case I think it's better to use POST.

like image 44
robertcolumns Avatar answered Oct 22 '22 15:10

robertcolumns