Jump to content

problem with database insert on refreshing webpage


geroido

Recommended Posts

Hi all

I have a webpage where the user can enter menu items(name, description, price etc.) and they are inserted into a database on clicking the 'save' submit button. It all works well. However, if I enter the information and click save, it works but if I then refresh the page, it puts the record into the database again and again and again if I keep refreshing which I don't want. Can you give me an idea what might be the problem. I'm not including any code now, just looking for ideas. I can submit the code if it helps.

Any user can repeatedly submit a form if they know what they're doing. All they gotta do is revisit the page that processing was done on. What I'd suggest is before doing an insert, do a query searching for a row with all of the inputted credentials that are exactly the same. If you get a mysql_num_rows() > 0 then you can know if was refreshed and then skip the INSERT query. That's really the only way to protect refreshing from inserting multiple times.

Hi dannyb785

I think that's a good idea too. I have a couple of options now so thanks for that. Do you also think it would be possible to clear all the variables after insert so that the form validation would fail and therefore present the user with the form again for completion but as a result of failed validation would not do any insert?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.