开发者

Form Double Post Issue

I understand that double posts has been a problem with 开发者_高级运维forms forever.

I am using the token server-side method to handle this issue, but I find that it doesn't seem to work flawlessly. I have the system set to create a unique token for every form, and then record that token in a SESSION after it has been posted.

The SESSION is actually an array of every form the user has ever posted (to be reset when the SESSION expires), and on each submit the system checks in_array() to see if that form has ever already been posted... if so then it stops them.

Seems like in production the system cannot record the completed token into the SESSION quick enough to deal with double clicks on the submit button. So revisiting an old page is handled fine, but the immediate double click of the submit creates a problem.

Not sure what I can do to fix this issue.


How about disabling the submit button immediately upon clicking (via Javascript, with an onClick handler)? This obviously won't fix all issues, but it might cover the cases where the system isn't quick enough to record the token into SESSION.


I have had this issue as well with something internal for the company I am working for. In my experience people click multiple times because they don't think anything is happening. What I have done is to remove the ability to submit the form and display some sort of message saying that the information is being processed.

Pop-up divs and just disabling the button work well.


I had same problem and I resolve with jQuery. I added class singleClick in submit button there I would like to have single click and also added some javascript code

<input type="submit" class="singleClick" value="Send Request">
    $(function () {
        $('.singleClick').on('click', function () {
            $(this).attr('disabled', true);
        });
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜