开发者

Pagination and $_POST

I want to do a search with pagination, but I don't know how to 'store' the data in the $_POST array, should I 开发者_C百科do it with sessions?

Rolensen


If you are doing a search, you are trying to GET data from the server, and not send data to it -- which means you probably should use GET, and not POST.

Also, it would allow your users to bookmark the result pages (or send those links by e-mail, IM, ...), which is always nice ; and, also, use the back/forward buttons of the browser without getting an alert box, which is nice too ^^

(Oh, and, BTW, it would help solve your problem ;-) )


Yes, you can use sessions or hidden fields and even better GET method in your form.


It is possible to use both GET and POST in form, just add appropriate attribute method to form tag:

<form action="index.php?page=5" method="POST">

So the pager links are submit buttons while rest of the data is stored in hidden fields. But that's not a good way to do this because you cannot pass someone link (on IM for example) to your search results.

But the best way is to store somewhere POST input data (look here: http://www.symfony-project.org/plugins/, when you input your query once, it is stored and remembered so you dont need to fill form multiple times)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜