在提交表单后重定向是一种好习惯吗? [英] Is it a good practice to redirect after a form has been submitted?

查看:70
本文介绍了在提交表单后重定向是一种好习惯吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在我网站上的某些表单提交后(主要与购物车应用程序相关)执行 header() 重定向(到同一页面),这样用户就不会做意外的事情刷新页面或通过后退"或前进"并刷新页面.这是可以接受的做法吗?

I've recently taken to doing a header() redirect (to the same page) after certain forms on my website have been submitted (mostly related to a shopping cart application) so that the user doesn't do unintended things by refreshing the page or by going "back" or "forward" and refreshing the page. Is this an acceptable practice?

推荐答案

这是标准做法,称为 redirect after post发布/重定向/获取.在处理帖子表单时,这被认为是最佳实践

This is standard practice called redirect after post or Post/Redirect/Get. It's considered best practice when dealing with post forms

这篇关于在提交表单后重定向是一种好习惯吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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