How to prevent form resubmission when page is refreshed (F5 / CTRL+R)

后端 未结 23 1805
醉话见心
醉话见心 2020-11-22 00:46

I have a simple form that submits text to my SQL table. The problem is that after the user submits the text, they can refresh the page and the data gets submitted again with

23条回答
  •  感动是毒
    2020-11-22 01:39

    I would also like to point out that you can use a javascript approach, window.history.replaceState to prevent a resubmit on refresh and back button.

    
    

    Proof of concept here: https://dtbaker.net/files/prevent-post-resubmit.php

    I would still recommend a Post/Redirect/Get approach, but this is a novel JS solution.

提交回复
热议问题