Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP clear browser cache to avoid form data resend after refresh
    primarykey
    data
    text
    <p>I'm developing a PHP-MySQL app that enables registered users to enter text comments. Problem is:</p> <ol> <li>User sign-in into the web site - OKAY</li> <li>User presented with a form to submit text comment - OKAY</li> <li>User enters text comment and submits - OKAY</li> <li>I have a routine that sanitize the comment &amp; save it into MySQL (with userid, textcomment, datetime stamp) &amp; present back the user that his/her comment is entered - OKAY</li> <li>User decides to refresh browser - a duplicate comment is entered - BAD!</li> </ol> <p>I was thinking 3 options:</p> <ul> <li>OPTION 1: Routine that checks: last time user posted comment, and if so, check if this is a duplicate. If duplicate then display error message.</li> <li>OPTION 2: Routine that does not allow a user to post too quickly. So basically do not allow postings of comments within 1 minute or so. So if browser is refreshed the comment will be ignored.</li> <li>OPTION 3: Manipulate the browser cache to clear out its contents so when refreshed no duplicate will be entered.</li> </ul> <p>Now in the context of my application, my concerns with OPTION 1 and OPTION 2 is performance PHP-MySQL since I already have various queries within the same page that push/get data from databases. So OPTION 3 may target the issue differently.</p> <p>Questions is: If I go for OPTION 3 can this be considered a Best Practice? meaning clearing the browser cache is the best most effective solution? I have read that there are consequences too? your thoughts are appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload