Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of PHP data submission and filtering

Shulou Source: shulou.com Published: 2022-06-03 19:36:26 11月12日 Update

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. "

Tags: Characters strings information arrays users caches addresses paths functions menus names files sites generation data content columns time processing parameters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Xiaomi Linux NVidia