Hi,
I’m pretty new at PHP and trying to figure out what’s the best way to handle validation. In my current project I tried to separate out everything as best I could. As an example, here are the files I have for one task (adding a question to an exam):
add_question.php (displays the interface/form)
add_question_process.php (validates the form and calls functions in question.php)
question.php (a library file that does the backend work with the database)
To me it seems really sloppy sending all the form data to another page, validating it there, and then having to send the data back through the header function as GET variables, when you could just submit the form to itself, validate it there, and then call the required functions in question.php.
So my question is what is the better method to handle this? Is it best to make everything separate or is it a more common and accepted practice to include validation in the file containing the form?