I think this is a common issue.
Whenever there is a form on a web page, there is a PHP file on the back-end processing the data sent from the form. You start with $_POST
, You need to ensure that the names of input elements are not falsified, increased or decreased, and you want to make sure that no input elements are left blank, and you also need to escape quotation marks, so you may need to employ isset()
, empty()
, mysql_real_escape_string()
or other functions to do this routine work before you apply business logic to these data.
What's the best way to do this routine work?
I want to write less code, and make it robust.
Maybe there are no best way, but at least there are good ways to do it. How to do it?
For the sake of convenience, suppose there are data like username, password, title, content, question, answer,unit_price,...
What if I don't use any PHP framework?