How to prevent refresh page error while submitting POST form?

前端 未结 4 1355
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 22:22

When registration form submits using POST method and when you refresh the same page then it will prompt for resubmit or resend information. How we can prevent this?

4条回答
  •  情歌与酒
    2020-12-19 23:09

    You can use include a one-time random token in the form. The first time that token is submitted (with other data), an action is taken. Future submissions of the same token have no effect (or just show the same confirmation page), and submissions with blank or invalid tokens are rejected.

    This also protects against cross-site request forgery.

提交回复
热议问题