2

I am running a page through Drupal so that it renders a form on the page from a SQL database. That is working OK. I've put in textfields and a button at the bottom so users can enter in rows to the database. That is also working OK. The database updates and all is fine.

The issue I'm having is that every page refresh re-adds the data they just entered on a new line, creating duplication. Even when there is no text in the fields, it remembers what was typed from before and re-adds it. I'm assuming it has something to do with my variables storing the information.

I have tried nulling the variables before and after the SQL statements run, but that has not fixed the issue. Is someone able to have a look at tell me if they see anything?

My code is here - http://codepaste.net/rduqaw

jimps
  • 65
  • 12
  • How are you refreshing the page? If you use F5 or the refresh button it may submit the POST data with the headers again, however if you were to type in the URL or press enter in the address bar it would reload with fresh headers.. – Matt Davis Nov 12 '15 at 03:03
  • Many things. One of them is: Don't quote column name in SQL query but values: mysql_query("SELECT * FROM testing WHERE Name = '$users_name' AND Phone Number = '$users_phone'"); – Kostas Mitsarakis Nov 12 '15 at 03:09
  • http://stackoverflow.com/questions/10827242/understanding-post-redirect-get – bassxzero Nov 12 '15 at 03:24
  • 1
    Common problem. Typically solved with Post/Redirect/Get pattern. I linked it or you can google it – bassxzero Nov 12 '15 at 03:25
  • @bassxzero Thanks for the idea mate, you got me reading and it lead to a different way of thinking of it. – jimps Nov 12 '15 at 05:40
  • @KostasMitsarakis Cheers mate, I fixed that up, appreciated. – jimps Nov 12 '15 at 05:41
  • @CynePhoba12 Nailed it. In addition to bassxzero comment, I added a redirect to refresh the page and that fixed it up. F5ing was resubmitting the same data again. – jimps Nov 12 '15 at 05:41

0 Answers0