Re: Double Submission into DB if Hit Refresh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Craig Hoffman" <choffman@xxxxxxxxxxx> wrote in message
news:7EEE5891-90CF-11D8-BFF4-0003935B61DA@xxxxxxxxxxxxxx
> What is the best way to avoid data being resubmitted (entered twice) to
> DB (mysql) if the user hits refresh after POSTING data via a form?

You can make it even more easy for inserts by using the SQL command IGNORE.
Just make the column with the unique transaction ID your primary key or (if
you don't use a auto-increment column) make your id column the primary key
and use:

INSERT IGNORE INTO table ...

So the record is only inserted if the primary key doesn't exist yet and just
ignores multiple inserts with the same id. This should work for MySQL - I
don't know if it works for other DBs as well.

I don't see a problem for multiple updates as the data usually won't change
between the refresh.

Regards, Torsten Roehr

> __________________________________
> Craig Hoffman - eClimb Media
>
> v: (847) 644 - 8914
> f: (847) 866 - 1946
> e: choffman@xxxxxxxxxx
> w: www.eclimb.net
> _________________________________

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux