handmade.network » Forums » Site Feedback » Accidentally hitting "submit" twice actually posts twice
cmuratori
Casey Muratori
803 posts
1 project

Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.

#10632 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago

Ie., https://hero.handmade.network/for...039-when_build_tools_matter#10631

My solution to this problem generally is to generate a GUID for the edit page, so that if you submit it twice, it's clear to the server that it's a resubmit and it drops the second one automatically. Not sure if that's how other people do it, but I'm sure there are other methods too...

- Casey
Kelimion
Jeroen van Rijn
237 posts
3 projects

A big ball of Wibbly-Wobbly, Timey-Wimey _stuff_

#10633 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago

cmuratori
Ie., https://hero.handmade.network/for...039-when_build_tools_matter#10631

My solution to this problem generally is to generate a GUID for the edit page, so that if you submit it twice, it's clear to the server that it's a resubmit and it drops the second one automatically. Not sure if that's how other people do it, but I'm sure there are other methods too...

- Casey


I had another similar solution for this in mind and it's on my todo list. Meanwhile I'd _just_ cleaned up the post in question before you posted this :)
AsafG
Asaf Gartner
29 posts
#10702 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago

cmuratori

My solution to this problem generally is to generate a GUID for the edit page, so that if you submit it twice, it's clear to the server that it's a resubmit and it drops the second one automatically.


That's generally known as a CSRF token. It's used to prevent other websites from tricking their users to POST to your website, but if you generate a unique token per page you get the double-submit prevention for free.
An additional approach is to disable the submit button after the first click.
Kelimion
Jeroen van Rijn
237 posts
3 projects

A big ball of Wibbly-Wobbly, Timey-Wimey _stuff_

#10704 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago Edited by Jeroen van Rijn on Feb. 3, 2017, 4:06 a.m.

AsafG
cmuratori

My solution to this problem generally is to generate a GUID for the edit page, so that if you submit it twice, it's clear to the server that it's a resubmit and it drops the second one automatically.


That's generally known as a CSRF token. It's used to prevent other websites from tricking their users to POST to your website, but if you generate a unique token per page you get the double-submit prevention for free.
An additional approach is to disable the submit button after the first click.


We have CSRF, just unique per session and not per page. We could do that, but that complicates things a bit tracking and expiring them, which also means that if someone's writing something rather long, they'll have an expired token that you have to then refresh on the fly based on their other session credentials and what not.

I prefer doing that just for pages with forms, much less to keep track of, i.e. separate from the CSRF. Also, the solution I have in mind is even simpler. More on that in March after I've implemented it. Abner won't let me work on the site this month unless it's an emergency, and this occurs so rarely it doesn't qualify.
abnercoimbre
Abner Coimbre
209 posts
2 projects

Community Manager

#10705 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago Edited by Abner Coimbre on Feb. 3, 2017, 4:23 a.m. Reason: Formatting.

Abner won't let me work on the site this month unless it's an emergency, and this occurs so rarely it doesn't qualify.

And to clarify, this month we're focused on the educational materials roadmap for HMN. We're also taking a short break from active development—celebrating the release of v1. The team worked really hard this past month and some rest is worthwhile; however, any site maintenance will still be performed (obviously).

Programmer for a certain space agency
Kelimion
Jeroen van Rijn
237 posts
3 projects

A big ball of Wibbly-Wobbly, Timey-Wimey _stuff_

#10706 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago Edited by Jeroen van Rijn on Feb. 3, 2017, 4:16 a.m.

abnercoimbre
however, any site maintenance will still be performed (obviously).

So much for my dastardly plan to let spam bots run amok the whole month… *twirls his moustache*
abnercoimbre
Abner Coimbre
209 posts
2 projects

Community Manager

#10707 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago

Sigh. It would be nice if the world was just nice enough to at least not have any spam bots. Out of all the horrible events that take place on planet Earth, spam bots need to exist as well? Really?

Programmer for a certain space agency
Kelimion
Jeroen van Rijn
237 posts
3 projects

A big ball of Wibbly-Wobbly, Timey-Wimey _stuff_

#10708 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago

abnercoimbre
Sigh. It would be nice if the world was just nice enough to at least not have any spam bots. Out of all the horrible events that take place on planet Earth, spam bots need to exist as well? Really?

Preaching to the choir - I'd say quire, but Eisbehr hasn't released it yet -, Abner. Dealing with those soaked up most of my time this month, as people will be able to read in the monthly update this month, when it's updated to update them on the updates this month.
Todd
94 posts

I use x86-64 assembly, Python, C, and SQL to fight malware.

#10709 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago

New Handmade project - Anti-bot bot aka BotKiller.

I'm the smartest man in Athens because I know that I know nothing. ~ Socrates
abnercoimbre
Abner Coimbre
209 posts
2 projects

Community Manager

#10717 Accidentally hitting "submit" twice actually posts twice
8 months, 2 weeks ago Edited by Abner Coimbre on Feb. 3, 2017, 4:12 p.m. Reason: Formatting.

Kelimion
Dealing with those soaked up most of my time this month, as people will be able to read in the monthly update this month, when it's updated to update them on the updates this month.

Said monthly update is now here.

Programmer for a certain space agency