Example Analysis of PHP data submission and filtering
Editor to share with you the example analysis of PHP data submission and filtering, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The details are as follows:
1. Basic principles of filtering php submission data
1) when submitting variables to the database, we have to use addslashes () to filter, like our injection problem, an addslashes () is done. In fact, when it comes to variable values, the intval () function is also a good choice for string filtering.
2) Open magic_quotes_gpc and magic_quotes_runtime in php.ini. Magic_quotes_gpc can change quotation marks in get,post,cookie to slashes.
Magic_quotes_runtime can act as a format for data going in and out of the database. In fact, this parameter was very popular as early as when the injection was crazy.
3) when using system functions, you must use escapeshellarg (), escapeshellcmd () parameters to filter, so that you can rest assured to use system functions.
4) for cross-site, both strip_tags () and htmlspecialchars () parameters are good, and tags submitted by users with html and php will be converted. Like angle brackets. "