Unset post variables after form submission

前端 未结 10 1161
礼貌的吻别
礼貌的吻别 2020-12-10 14:19

Is there a way to do the above? Basically, I don\'t want the form to be submitted again if someone presses refresh after already submitting the form once. In which case the

10条回答
  •  独厮守ぢ
    2020-12-10 15:11

    The problem you are facing above specifically can (and should) be solved with Post/Redirect/Get. Unsetting _POST on the php side would be ineffective since the problem is it is a separate request.

    You also have to deal with double-clicking of submission buttons. You can solve this on the client side by disabling form submission after the button click, or by putting a random token in the form and storing that token in the session. The token will be accepted only once (session keeps track of whether the token has been posted).

提交回复
热议问题