当按下后退按钮时,重新提交表格 [英] Form is resubmitted when the back button is pressed

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

问题描述

我使用HTML和PHP制作的联系表存在问题.当用户单击 submit 时,它将重定向到用户收到消息的另一页,您的消息已发送".然后,它会自动重定向到主页.但是,当用户单击 back 按钮时,该消息再次出现,并且重新提交了表单.因此,我收到了两条相同的邮件发送到我的电子邮件!

I have a problem with my contact form that I have made using HTML and PHP. When the user clicks submit it redirects to another page where the user gets the message, "Your message has been sent". It then automatically redirects to the home page. But when the user clicks the back button, the message appears again and the form is resubmitted. Consequently I get two identical messages sent to my email!

我该如何解决?

推荐答案

看看防止表单重新提交防止后退"按钮显示POST确认警报,您将找到有用的信息,该信息如何进行重定向,当单击后退"按钮时,该重定向不会触发重新提交表单.

Take a look at Preventing form resubmission and Prevent Back button from showing POST confirmation alert where you will find useful info how to make redirects which won't trigger form re-submission when the Back button is clicked.

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

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