How to prevent page refresh from adding new records

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tokunbo
Forum Commoner
Posts: 46
Joined: Thu Sep 29, 2011 8:53 am

How to prevent page refresh from adding new records

Post by Tokunbo »

hello sirs,

In-line with some earlier posts I made, I have a code that allows a user to enter a name and surnname and these get inserted into a table. This works fine, no issues.

I have observed that if I refresh my page / use the F5 button, the previous record which I entered into the input boxes gets inserted again - thus I have two rows in my table with same info. Is there a way to prevent this and make sure the user uses only the submit button?

as in even if the page is refreshed, a new record(same as before) wont be added?

please note, Im not referring to trying to add the same record twice, its just the refresh thingy.

I was thinking of sessions, but I thought its supposed to be used when a user navigates, for ex: from a page1 to page2...... In my code, im posting to the same page / just inserting records into my db

thanks
Toks
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to prevent page refresh from adding new records

Post by Celauran »

Tokunbo
Forum Commoner
Posts: 46
Joined: Thu Sep 29, 2011 8:53 am

Re: How to prevent page refresh from adding new records

Post by Tokunbo »

@celauran

thanks man, you're 2much
Post Reply