Re: [PHP] Preventing double-clicks
Jay, I use a technique to prevent hitting the back button and resubmitting data. I use a 2-script process, one with the form and submit button (I set a session var here), and a second form (the action script). The action script makes sure the session variable is set, processes the info, then clears the session var. If the session var is not set, an error is displayed. Gerry On 6/26/06, Jay Blanchard [EMAIL PROTECTED] wrote: I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. The steps are; 1. Fill out form 2. Click 'Submit' 3. Data gets stored (including unique data and time stamp data in this casewhich should work out well) If the process sees the unique data and a timestamp sometime within the last minute it should ignore the subsequent attempt. 4. A reply is returned to the user based on the first click. The data returned to the user would be different for each click, that is why this is so important. The first data returned is the correct data. My confusion is in this (as I have mentioned in the past couple of weeks, most of the confusion is as a result of a lack of rest, which leads to not thinking clearly, which leads to me feeling ignorant); upon the second click, where I check to see if the data has been entered and find that it has how do I get it to return the data back to the user. I think I see it now..let's see.if I; Select * from foo where data is what it is and time is within last interval that I decide upon; if(1 == mysql_num_rows(that query up there)){ get that data for return to the user; } else { Insert data, do calcs, return data back to user; } Does that look reasonable, or am I missing something? Thanks for any insight! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks APPEARS TO WORK FINE
Jay Blanchard wrote: [snip] JavaScript can't be used for such things, or at least it can't be relied upon. What if the user has disabled JavaScript? Or what if the user has specifically disabled the JavaScript behaviour you are relying on? [/snip] Egg Zachary. That was why I wanted a PHP method. Since the SESSION data is set for the activation receipt I do not have to query the database again, save for the initial query to check and see if the data exists. You're still doing two round-trips to the server, which seems very inefficent to regulate user behavior. -- Online library -- http://pueblonative.110mb.com 138 books and counting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Preventing double-clicks
I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. The steps are; 1. Fill out form 2. Click 'Submit' 3. Data gets stored (including unique data and time stamp data in this casewhich should work out well) If the process sees the unique data and a timestamp sometime within the last minute it should ignore the subsequent attempt. 4. A reply is returned to the user based on the first click. The data returned to the user would be different for each click, that is why this is so important. The first data returned is the correct data. My confusion is in this (as I have mentioned in the past couple of weeks, most of the confusion is as a result of a lack of rest, which leads to not thinking clearly, which leads to me feeling ignorant); upon the second click, where I check to see if the data has been entered and find that it has how do I get it to return the data back to the user. I think I see it now..let's see.if I; Select * from foo where data is what it is and time is within last interval that I decide upon; if(1 == mysql_num_rows(that query up there)){ get that data for return to the user; } else { Insert data, do calcs, return data back to user; } Does that look reasonable, or am I missing something? Thanks for any insight! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Preventing double-clicks APPEARS TO WORK FINE
[snip] I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. [/snip] Because the data is contained in session variables this became an easy issue once I logiced it out /* * we have to find out if a double click occurred but we are going to allow for a much longer time interval * of 30 minutes in order to make sure that the ESN can be provisioned again, just not today. */ $getESNDate = SELECT `ezESN` FROM `test`.`provision` ; $getESNDate .= WHERE `updated` BETWEEN DATE_SUB(NOW(), INTERVAL 1800 SECOND) AND DATE_SUB(NOW(), INTERVAL 1 SECOND) ; $getESNDate .= AND `ezESN` = '.$_POST['psESN'].' ; if(!($dbESNDate = mysql_query($getESNDate, $udc))){ echo mysql_error(); exit(); } /* does it test positive for ESN within the past few minutes? */ if(0 != mysql_num_rows($dbESNDate)){ /* the session data is already set, so go to activation receipt */ header(Location: ezActivationReceipt.php); exit(); } else { /* process normally */ /* lines and lines of code */ } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks APPEARS TO WORK FINE
Jay Blanchard wrote: [snip] I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. [/snip] Isn't there a javascript method that you could use to accomplish the same thing? Either that, or on the first click, you could disable that button. -- Online library -- http://pueblonative.110mb.com 138 books and counting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks APPEARS TO WORK FINE
On Mon, June 26, 2006 2:05 pm, John Meyer said: Jay Blanchard wrote: [snip] I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. [/snip] Isn't there a javascript method that you could use to accomplish the same thing? Either that, or on the first click, you could disable that button. That would be the Javascript method to accomplish the same thing. :-) It's probably more efficient than a PHP-based solution, modulo the usual Javascript caveats (user can disable, etc.). --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks APPEARS TO WORK FINE
John Meyer wrote: Jay Blanchard wrote: [snip] I am going to do some thinking (typing) out loud here because I need to come up with a solution to double-clicking on a form button issue. [/snip] Isn't there a javascript method that you could use to accomplish the same thing? Either that, or on the first click, you could disable that button. JavaScript can't be used for such things, or at least it can't be relied upon. What if the user has disabled JavaScript? Or what if the user has specifically disabled the JavaScript behaviour you are relying on? For example, some websites very wrongly try to disable right-clicking on webpages. Firefox provides an option (I'm not sure if it is enabled by default) that prevents pages from disabling right-click. So using said JavaScript code to disable right-clicks is not a valid way of preventing people from viewing page source or downloading files. The same would apply to any other security measure; it'd be just fine to use JavaScript to discourage multiple clicks, but it wouldn't solve the underlying problem; he'd still have to solve the problem on the backend. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Preventing double-clicks APPEARS TO WORK FINE
[snip] JavaScript can't be used for such things, or at least it can't be relied upon. What if the user has disabled JavaScript? Or what if the user has specifically disabled the JavaScript behaviour you are relying on? [/snip] Egg Zachary. That was why I wanted a PHP method. Since the SESSION data is set for the activation receipt I do not have to query the database again, save for the initial query to check and see if the data exists. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks APPEARS TO WORK FINE
Jay Blanchard wrote: [snip] JavaScript can't be used for such things, or at least it can't be relied upon. What if the user has disabled JavaScript? Or what if the user has specifically disabled the JavaScript behaviour you are relying on? [/snip] Egg Zachary. That was why I wanted a PHP method. Since the SESSION data is set for the activation receipt I do not have to query the database again, save for the initial query to check and see if the data exists. I found that my own problem with double click was caused by simply not updating the session flag early enough! i.e. before trying to do anything with the database connection ;) -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing double-clicks APPEARS TO WORK FINE
Hi gang: I don't know who originally asked, but if you generate and use a token with a session, you can prevent double posting (clicking). tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php