Discussion Forum

[deck builder]add to many cards

I'm not sure if it does it on your initial build. but when I went to edit a deck of mine I added a few cards in, I then refreshed the page and it added all of the cards again, so I went from having 1 master of cruelties to 2, 3 xathrid necromancers to 6, etc.
Posted 07 August 2013 at 17:06

Permalink

Unfortunately with the way .NET and form submitting works, if you press F5 to refresh and get the message "Do you wish to resubmit the form?" (or something similar), if you get Ok, it will resubmit the last form. Which in you case, probably meant it re-did all the cards you just bulk imported?

Hope that makes sense :p
0
Posted 07 August 2013 at 21:59

Permalink

Yea that makes sense. I wasn't sure if there was anything you could do about it or not. Sorry about that!
0
Posted 08 August 2013 at 17:04

Permalink

[QUOTE=Ian]Unfortunately with the way .NET and form submitting works, if you press F5 to refresh and get the message "Do you wish to resubmit the form?" (or something similar), if you get Ok, it will resubmit the last form. Which in you case, probably meant it re-did all the cards you just bulk imported?[/QUOTE]

A little trick you can use to prevent double-posts via F5...

Create a session variable for duplicate-checking. Add a hidden field to the form and assign a randomized string to it with each new page request. Upon submission, compare said string to the session variable. If the form field and session variable are identical, then you know the form was submitted twice (eg. F5). If the form field and session variable differ, then you know the form was submitted anew; copy the form field value into the session variable so you're ready for the next comparison. And so for a duplicate submission, skip the db insert/update.

For example in PHP:
if(array_key_exists('_token', $_POST)) {
if($_SESSION['_post_token'] == $_POST['_token']) {
$_post_duplicate = true;
}
else {
$_post_duplicate = false;
}
}
0
Posted 08 August 2013 at 18:52

Permalink

Ahh nice. That sounds like a pretty neat trick. Will have a look. I can visualize how this would work in .NET.
0
Posted 09 August 2013 at 08:53

Permalink