Prevent browser waring when you hit the 'go back' button after form submit

夙愿已清 提交于 2019-11-28 11:13:30

问题


I have a little problem here. Actually, more of an annoyance.

I have a form on my index page that has a small search form:

<form action="search.php" method="post">
<input name="search" type="text" />
<input type="submit" name="submit">

now on the search.php file I just use the $_POST['search'] to retrieve the value that I'm searching. This file also displays the actual search results, which I can click on to go to that page.The search is actual done on the database. Also, because my search returns the top 10 random results from the DB, if I hit the 'back' button and confirm the warning, the search will be executed again, and will return a different set of results.

The problem, as you know, is that when you click on one of the search results and then hit 'back' on the browser, you get that browser warning about 'To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.'.

What's the easiest way to prevent this from happening? I looked into that PRG technique but I'm not sure how to implement that.

Any help would be great. Thanks. Bruno.


回答1:


Is it OK to use GET method here, users won't see warning if form sent by GET method.



来源:https://stackoverflow.com/questions/5687083/prevent-browser-waring-when-you-hit-the-go-back-button-after-form-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!