Re: Avoid inserting a duplicate record on page submit?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




Dale wrote:
If, in the normal course of business, you add duplicate data to the table,
how do you know which to retrieve later?

Hi Dale,

Lol, I'm surprised this has become such a difficult issue, and that
no-one seems to want to touch my original question, despite it being
extremely legitimate in web design.

Oh well. Cough. Hmmm. Imagine, if you will, a simple web app used to
record activity. Imagine then, that you may perform the same action on
the same task several times. Imagine also that you as a developer have
been asked to build an interface that allows 'type-click-click-submit'
functionality (one text box, two list boxes and a submit button) and,
very importantly, that a user might legitimately record exactly the
same information several times in a row.

Now, imagine that all that's really going to be used out of this is a
count of records per activity, per task, per user id, per day.

Now, just for the sake of the argument, and without running off on a
'unique key! unique key!' tangent, how would you minimize the
opportunity for accidental insertion of duplicate records by a page
refresh?

I've already explained how I would achieve this in PHP. You will see
the "entrypage.php --> processpage.php --> entrypage.php" technique
used a lot on sites for inserting blog comments, for example - where a
page refresh might otherwise insert a duplicate comment, but where
multiple comments by the same person is very normal.

I agree, in principle, that a unique key would have been an ideal
solution, if it were applicable. But, sadly, unless someone can see
something I'm missing, it's not.

Much warmth,

planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org

.



Relevant Pages

  • Re: I am still around
    ... PS I'd imagine they'd have to give the iPhone another refresh at ... somepoint this year. ...
    (uk.comp.sys.mac)
  • Re: Friday Fun-run
    ... Imagine what your life would be like if hadn't posted ... Just found out you may need to refresh the page to get to the good one. ... song made famous by a band that died in a plane crash. ...
    (microsoft.public.cert.exam.mcse)
  • Re: 11.5 minutes & Etherfast BEFSR41 Puzzle
    ... > the router that doesn't have teh brains to refresh? ... > they could ship routers with code like that without loads of people ... <<< I would imagine this situation doesn't represent the typical ...
    (comp.security.firewalls)