Forum Moderators: coopster

Message Too Old, No Replies

problem in inserting record from php to mysql

duplicate records added in the db when i refer the same page after insert

         

sanindhya

5:18 am on Jan 21, 2004 (gmt 0)

10+ Year Member



I have a page product master(product.php) after getting the details from the user this page will store it in mysql db. Then I refer this same page for another insert operation. Its come to the same page successfully, but the problem is when i press refresh button(without enter anything in the page) of the browser it stores the previous record in the db. I need solution for this asap.

Thanks in advance.

tomda

6:00 am on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't you use the if statement and may be an other variable so that it doesn't take into account the previous query.

For the first submit
$i = 1;
Insert query1
Submit -> $i++

For the second submit
$i = 2;
if ($i=2) {ignore the insert query1; make query2)
Submit -> $i++

and so on...

Just a thought

Tommy