Forum Moderators: coopster

Message Too Old, No Replies

insert data again in database with refresh

         

codefusion

6:39 am on Oct 18, 2007 (gmt 0)

10+ Year Member



Hello friends,

i have an insert statement in a php pagae but wen i hit refresh then the data again insert in the database i want to prevent this!

vincevincevince

6:51 am on Oct 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are many ways to do this, here are a few:
1) After insert, redirect to a new URL
2) Set a 'form key' hidden field in the form with something like time() or uniqid() in it, insert it into the table with the submission, and make the field UNIQUE
3) Use POST not GET, at least you get a warning before you resubmit
4) Do a check (SELECT ....) for data which exactly matches the new data before deciding whether to INSERT

Habtom

6:53 am on Oct 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can control this in many ways. It depends on the code you have written so far, but cleaning up the values after inserting them or something of a similar concept should be easy to implement.

Habtom

Habtom

6:57 am on Oct 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



vincevincevince, similar ideas I had.

Are you a remote mind reader. It seems we have become early morning mates ;)