I have a web application using coldfusion and mysql. There is a form where
customer's payment is entered and submitted. Upon submission customer's
balance is updated. Sometimes customer's balance is updated twice.
How do I prevent this from happening?
Example:
Balance: 1000
payment: 100
After update: balance = 800
Without seeing your code, it's hard to make specific suggestions. But one solution is to generate a unique identifier, something like a transaction or order id. When the user clicks submit, the application should check if payment has already been made for this id. If so, then it has found a duplicate payment.
0
SonnyReyAuthor Commented:
how do you make a unique id? Cannot make a unique id based on time.
transactid is the primary key for transact, and yet the insert statement above does not include that column, so I assume that has integer auto_increment in your definition. I think what you need to do is to already insert a row to the transact table before processing payment (so payment column is currently null), note the generated transactid, then make it part of the form, maybe as a hidden field.
Then when the form is submitted, a check is made if the row with that transactid already has a value for payment. If so, then it is considered a duplicate and nothing else happens. If not, then the usual balance update should proceed.
0
SonnyReyAuthor Commented:
That might work. Let me try it.
Thanks.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.