sunilvadranapu Posted April 12, 2007 Share Posted April 12, 2007 Hi, I have one form for collecting feedback from users. On submitting the form, it inserts a record in to the database. I am using Postgresql as database. This is working fine for me. but, if I refresh the form after inserting a record, again it is inserting a new record with the same POST data. For each refresh, a new record is going into the database. How to overcome this problem. any idea???? -SunilKumar Link to comment https://forums.phpfreaks.com/topic/46705-new-record-inserting-on-refresh-the-form/ Share on other sites More sharing options...
dymon Posted April 12, 2007 Share Posted April 12, 2007 Hi, one solution can be to clear the _POST variable. other solution is to check after submit if such a record was already inserted into the database (I mean to make a SELECT), and if this record exists than just do not insert it. Dymon Link to comment https://forums.phpfreaks.com/topic/46705-new-record-inserting-on-refresh-the-form/#findComment-227529 Share on other sites More sharing options...
sunilvadranapu Posted April 12, 2007 Author Share Posted April 12, 2007 We can do that but it involves fetching all records from database and comparing with POST data which takes much time to process. If we are able to check at front end itself that would be better i think. Can't we process /eliminate this at front end itself? any ideas??? -SunilKumar V Link to comment https://forums.phpfreaks.com/topic/46705-new-record-inserting-on-refresh-the-form/#findComment-227531 Share on other sites More sharing options...
paul2463 Posted April 12, 2007 Share Posted April 12, 2007 when the page information is posted, you send it away to another php page that enters it into the database and then using the header() command go to another page which ditches all the posted variables so it cannot be refreshed Link to comment https://forums.phpfreaks.com/topic/46705-new-record-inserting-on-refresh-the-form/#findComment-227550 Share on other sites More sharing options...
jitesh Posted April 12, 2007 Share Posted April 12, 2007 Now keep a flow like this 1. create a file form.php in which place form and feilds <form name=a action="add.php"> ............. 2. now in add.php file dont database operation and aftrer that you redirect to amother file like this .... ..... header("location:thank_you_for_feedback.php"); or header("location:form.php"); Link to comment https://forums.phpfreaks.com/topic/46705-new-record-inserting-on-refresh-the-form/#findComment-227556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.