How do I stop the Back and Refresh buttons from resubmitting my form?

后端 未结 13 1282
时光说笑
时光说笑 2020-11-27 15:16

I am doing web development.

I have a page to do with credit card, which when user click \"refresh\" or \"Back\", the transaction will be performed one more time, wh

13条回答
  •  旧巷少年郎
    2020-11-27 15:29

    The simple fact that resubmitting the form generates a duplicate transaction is worrying. You should have some sort of check to ensure each submit of form data is unique.

    For example, the page which would submit the form should be given a unique ID that gets submitted with the form. The business logic should then be able to recognise that the form submitted has already been processed (as the (no longer) unique ID will be the same), so ignores the second attempt.

    The 'standard way' still doesn't stop clients from clicking the back button twice... or even going back and resubmitting the form if they don't think (for whatever reason) it has been processed.

提交回复
热议问题