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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.