Preventing Information to be "Updated" More than O

I’m developing a PHP quiz script with MySQL. When you enter answers, it updates the answer section of the MySQL table. However, you can override your old answers, somethign which I dont what people to be able to do, by just submitting again. Is there any failsafe way to, using PHP or MySQL, either stop this script being called more than once, or stop the table being written to more than once?

under your primary key use maybe their first and last name with class section number (EX: Joe Smith cs1001-003). Granted this assumes that in each class there will not be any 2 people with the same name but I think you get the idea. Or they can use their SSN (though I wouldn’t suggest it) or a randomly generated number the teacher assigns them to use all semester. It just must be unique to them. Then when they take the test they input that data first. Search the DB for that unique identifier and if it already exists for that test - kick them out telling them they have already taken the test.

Im not exactly doing this for teaching, its for something much less important than that, but I get the idea - making sure that a certain row does not exist seems to be the best idea. Thanks :D

Sponsor our Newsletter | Privacy Policy | Terms of Service