防止刷新时重复提交表格 [英] prevent double form submission on refresh

查看:74
本文介绍了防止刷新时重复提交表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题.我知道,当用户使用发布/重定向/获取模式"重新加载页面时,可以防止表单重新提交自身.但是我的问题是,如果我将用户重定向到提交表单的同一页面,此模式是否有效?我的意思是,我不想将用户重定向到另一个页面.

I have a simple question. I know that I can prevent a form to re-submit itself when the user reloads the page by using the Post/Redirect/Get Pattern. But my question is, will this pattern work if I'm redirecting the user back to the same page where the form was submitted? I mean, I don't want to redirect the user to another page.

请帮助

谢谢

推荐答案

是的,但是您必须记住在没有GET参数的情况下重定向他.

yes, but you have to remember to redirect him without the GET params.

这样您就可以

header('Location: same_page.php?status=done');
die();

这样,您就可以删除参数,并且需要支持status=done来显示消息或您想要的任何内容.

this way you are removing the param, and you need to support the status=done to show a message or what ever you want.

这篇关于防止刷新时重复提交表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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