magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2001 > 08 > Programming with Perl  

One-Click Processing

By Randal L. Schwartz

One problem that seems to plague many Web programmers is how to achieve "one click" processing. No, I'm not talking about A mazon's patented technology. I'm talking about circumventing that annoyance that occurs when a user clicks on a form's submit button two or three times before a response is returned to the browser.

This is no big deal if the request is idempotent: that is, if a repeated request generates a consistent result, and each in dividual request doesn't change the state of the world incrementally. However, many form submissions do intend to change the s tate of the world somehow. For example, a shopping cart form might have a "buy this item" button, and multiple clicks might en d up filling the cart with many copies of an item when the customer only wanted one. A survey form might return multiple votes from a single participant. Or, multiple copies of a message might appear in a guestbook or chat room.

The communities in which I participate frequently offer solutions to this problem that involve JavaScript. No offense to th e JavaScript coders, but more people than ever before are disabling browser scripting these days, thanks to the repeated CERT warnings of security holes—not to mention those evil sites with pop-up advertising windows. Some companies are even insta lling firewalls that strip the JavaScript at the corporate gateway—so it isn't even a choice for the user to "please enab le JavaScript," in many cases.

But luckily, there's a simple server-side solution. Simply generate the form with a unique serial number embedded in a hidd en field, and record that number in a lightweight server-side database.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2