I’m using Zend forms. I have a form to add a row to a database, which then generates a form with an ‘Undo’ button, along with a hidden element with the id of the added row. The ‘Undo’ form is posted with that just hidden element as the post data, but I’m wondering if there is a way to make sure that it wasn’t modified, like with Javascript or something, so that only the most recently created row by that user can be deleted. Is that possible?
More details, if they are necessary: The constructor for the undo form takes the row id as a parameter, so I can’t add an ‘identical’ validator because the only data I can check against is what was posted in the ‘Undo’ form, not the ‘add’ form.
Also, I need a solution that doesn’t depend on Javascript.
Edit: Looks like sessions is the way to go. Got it working.
Your only choice is to validate the form on the back-end. Input from the user should not and cannot be trusted.
You could store the ID in the user’s session and validate the input against that.