Preserving User Input: Checkboxes, Radio Buttons, Etc.
Posted: Mon Sep 12, 2005 1:54 pm
I have an HTML form with a bunch of radio buttons, checkboxes, etc. The form either inserts a new record into the DB or it updates an existing one. The form knows which scenario to follow based on various hidden fields.
Here's the thing...In either case, the data has to pass a couple of validation rules contained within the same php file. If the submission fails one of these tests, I want the user to be returned to the form. I assume that, regardless of whether we're dealing with an update or insert, everything becomes accessible via $_POST at that point. But how would I handle checkboxes, radio buttons, and drop-down menus not only in that case but in original case of pre-populating with values from the database? How would I get, for instance, a radio button to highlight either the existing value in the DB or what the user has tried to submit?
Any help would be appreciated.
Here's the thing...In either case, the data has to pass a couple of validation rules contained within the same php file. If the submission fails one of these tests, I want the user to be returned to the form. I assume that, regardless of whether we're dealing with an update or insert, everything becomes accessible via $_POST at that point. But how would I handle checkboxes, radio buttons, and drop-down menus not only in that case but in original case of pre-populating with values from the database? How would I get, for instance, a radio button to highlight either the existing value in the DB or what the user has tried to submit?
Any help would be appreciated.