Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refresh problem

Status
Not open for further replies.

sgdragon78

Programmer
Oct 14, 2003
17
0
0
SG
Hi all
I have an inventory system. If the user selects a few delete and hit the "delete" button. Logically, the database figure will be adjusted.
But what is while the process is being run, he hits the reload button? Will the database figures be re-deleted again?
If so, is there any method to prevent this?

thanks and regards,
 
GUJUm0deL,

==========================
confirmDelete.cfm

<cfif isdefined(&quot;cmdSubmit&quot;)>
<cfquery name=&quot;delStock&quot; datasource=&quot;...&quot;>
delete from tbl_stockOnHand where id ='#chk#'
</cfquery>
<cfset msg =&quot;Item(s) deleted&quot;>
</cfif>

<form name=&quot;form&quot; action=&quot;post&quot; method=&quot;confirmDelete.cfm&quot;>
<input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;chk&quot;><br>
<input type=&quot;checkbox&quot; value=&quot;2&quot; name=&quot;chk&quot;>
<cfif isdefined(&quot;msg&quot;>
<cfoutput>#msg#</cfoutput>
<cfelse>
<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;cmdSubmit&quot;>
</cfif>
</form>
==================================================

This isn't my actual codings, but i'm just trying to convey the idea.
If the user clicks on the Submit button, the Delete SQL will delete from my table. But if user performs a REFRESH on the browser, while the page is loading, will the query be execute twice? In many case, i will have Update operations as well.

Regards,
sgdragon78
 
sgdragon78, i'm not sure. I tried this on a client's site where I deleted something, hot SUBMIT then hit refresh right away, and nothing strange happened. I don't think it would matter. Once an item is delerted, you can delete it again.

I'm not 100% sure, since it worked fone for me, i'm assuming it would work fine for you.

[sub]
____________________________________
Just Imagine.
[sub]
 
Whenever you refresh a page, the code for that page is going to get executed again. In the case of the delete, since you specified &quot;where id ='#chk#'&quot;, only the records with that matching ID will get deleted. If they were just deleted and the query is run again, nothing will happen because those records don't exist.

In the case of an update or insert, these queries will also be run again and whatever you're updating/inserting will be &quot;re-updated&quot;/&quot;re-inserted&quot; (are those even real words?).

That was all assuming the page had completed loading. Now, you said &quot;while the page is loading&quot;. Well, that's a whole other can of worms. How much of the page was loaded? What queries have/haven't executed yet? If the user clicks refresh, the page is going to start over, but how much is repeated depends on how much it got accomplished the first time...



Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
Ecobb,
Like what you mentioned, Updates and Inserts will really create a whole lot of mess. Imagine a Delivery Order operation, if the user keeps refreshing, the stock on hand will keep reducing, that leads to data inaccuracy, which is a very serious problem in Inventory point of view.
While the page is loading (maybe network traffic is heavy, slow data transfer), there isnt much way to tell which query has been executed rite?
There much be a way to work around this &quot;Refresh&quot; problem.
 
typo error, in my previos postings, i meant, &quot;there must be a way to work around this &quot;Refresh&quot; problem&quot;
 
Well, one way to work around it would be to have your &quot;action&quot; page contain nothing but the insert/update/delete query, followed by a <cflocation> tag directing them to another page. Maybe have a &quot;Processing...please wait&quot; sign there if you think the query will take a little time to run. That way, the user will hit the &quot;delete&quot; button, CF will load the page with the delete query, and immediately after the query is run CF will take the user to another page, like a &quot;Thank You&quot; or &quot;Processing Complete&quot; page. You still have the issue of the users hitting the &quot;Back&quot; button on the browser, but I really don't know how to get around that one. Just make the content on the &quot;Processing Complete&quot; page good enough they don't want to go to another page. :)
Code:
PROCESSING...Please Wait...Don't hit refresh!

<cfquery name=&quot;delStock&quot; datasource=&quot;...&quot;>
DELETE FROM tbl_stockOnHand 
WHERE id ='#chk#'
</cfquery>

<cflocation url=&quot;ThankYou.cfm&quot;>



Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top