Filtering $_POST data
The process of filtering data can encompass any or all of the following:
- Removing unwanted characters (that is, removing
<script>
tags) - Performing transformations on the data (that is, converting a quote to
"
) - Encrypting or decrypting the data
Encryption is covered in the last recipe of this chapter. Otherwise, we will present a basic mechanism that can be used to filter $_POST
data arriving following form submission.
How to do it...
- First of all, you need to have an awareness of the data that will be present in
$_POST
. Also, perhaps more importantly, you will need to be aware of the restrictions imposed by the database table in which the form data will presumably be stored. As an example, have a look at the database structure ...
Get PHP 7: Real World Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.