Preventing a user from resubmitting a form
Posted: Thu Mar 26, 2009 11:48 am
I am writing a short test of 10 multiple choice questions. After the user submits the test, he is shown his result, along with the correct answers. Soon after I did this I realized that he could then simply hit the "back" button, change his answers and re-submit. I'm looking for a convenient way to preventing this.
The test is comprised of randomly-selected questions, but hitting the back button doesn't regenerate the questions since it doesn't reload the page. The test-taker is also limited to taking the test a total of 3 times. The test is located behind a login system so I have a unique ID for each test-taker and an accompanying row in a MySQL database table where I store his information.
I have considered a time limit on how often the particular user can take the test, but that doesn't prevent him from just leaving the page up and then resubmitting it an hour later.
One workable solution I came up with, although it is pretty inefficient, is generating a unique ID for the particular test, storing that ID in the database, and making sure that the same test ID is not submitted twice. Since each test is comprised of the 10 randomly-selected questions (out of a pool of about 30), the chance of the user legitimately loading up an identical test (and thereby an identical ID) twice is rather small, and if this happens he can just reload the test to get a different one.
There has to be an easier way of doing this. Can anyone give me some feedback or point me in the right direction?
Thanks,
Marcus
The test is comprised of randomly-selected questions, but hitting the back button doesn't regenerate the questions since it doesn't reload the page. The test-taker is also limited to taking the test a total of 3 times. The test is located behind a login system so I have a unique ID for each test-taker and an accompanying row in a MySQL database table where I store his information.
I have considered a time limit on how often the particular user can take the test, but that doesn't prevent him from just leaving the page up and then resubmitting it an hour later.
One workable solution I came up with, although it is pretty inefficient, is generating a unique ID for the particular test, storing that ID in the database, and making sure that the same test ID is not submitted twice. Since each test is comprised of the 10 randomly-selected questions (out of a pool of about 30), the chance of the user legitimately loading up an identical test (and thereby an identical ID) twice is rather small, and if this happens he can just reload the test to get a different one.
There has to be an easier way of doing this. Can anyone give me some feedback or point me in the right direction?
Thanks,
Marcus