如何阻止某人返回上一页? [英] How to stop someone from going back to previous page?

查看:70
本文介绍了如何阻止某人返回上一页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的网站上工作,以允许用户进行测试,以便他们可以了解到对特定主题的了解程度.我遇到了一个小问题.用户提交测验以进行评分后,如何防止他们返回测验页面?我在运行Safari的Mac上运行,提交测试后单击Web浏览器中的后退"按钮时,我回答的所有答案均被填写.我希望这样做:当用户提交测试并单击Web浏览器中的后退"按钮时,它将重定向到主测试页面.

I am working on a my site to allow users to take test so they can see how much they know of a particular subject. I am running into a little problem though. Once a user submits the test for grading, how do I prevent them from going back to the test page? I am on a Mac with Safari running and when I click the back button in my web browser after I submit the test it leaves all of the answers I answered filled out. I want it do this: When a user submits a test and they click the back button in their web browser it redirects them to the main test page.

我正在使用PHP和MYSQL.我什至设置了测试页,以便用户必须来自某个URL(我使用的是HTTP_REFERER),并且我尝试了其他诸如会话之类的方法,但似乎无法弄清楚.任何帮助,我们将不胜感激.

I am using PHP and MYSQL. I even have the test pages setup so that the user must come from a certain url (I am using HTTP_REFERER) and I have tried other stuff such as sessions but I cannot seem to figure this out. Any help is greatly appreciated.

推荐答案

您不会阻止它们.

相反,请更改您的应用程序,即使它们返回,它也仍然可以运行.您可以在页面上的隐藏字段中嵌入一个唯一编号,如果他们重新提交相同的测试两次,则可以检测到该错误并显示相应的错误消息.您还应该考虑如果他们修改了唯一编号会发生什么情况.

Instead change your application so that it still works even if they go back. You can embed a unique number in a hidden field on the page and if they resubmit the same test twice you can detect it and display an appropriate error message. You should also think about what should happen if they modify the unique number.

这篇关于如何阻止某人返回上一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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