表单提交后点击“返回"按钮时防止浏览器警告 [英] Prevent browser waring when you hit the 'go back' button after form submit

查看:26
本文介绍了表单提交后点击“返回"按钮时防止浏览器警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有点问题.实际上,更多的是烦恼.

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:


<input name="search" type="text"/>
<input type="submit" name="submit">

现在在 search.php 文件中,我只使用 $_POST['search'] 来检索我正在搜索的值.这个文件还显示了实际的搜索结果,我可以点击它转到那个页面.搜索实际上是在数据库上完成的.此外,因为我的搜索会从数据库中返回前 10 个随机结果,如果我点击返回"按钮并确认警告,搜索将再次执行,并返回一组不同的结果.

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.

问题,如您所知,当您单击其中一个搜索结果,然后在浏览器上点击返回"时,您会收到有关要显示此页面,Firefox 必须发送会重复的信息"的浏览器警告之前执行的任何操作(例如搜索或订单确认).

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.'.

防止这种情况发生的最简单方法是什么?我研究了那个 PRG 技术,但我不知道如何实现它.

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.

推荐答案

这里用GET方法可以吗,如果用GET方法发送表单,用户不会看到警告.

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

这篇关于表单提交后点击“返回"按钮时防止浏览器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆