0
Good use the filter_input
thus:
filter_input(INPUT_POST, 'nome_input', FILTER_SANITIZE_SPECIAL_CHARS);
I wonder how I can use it in $_POST
for all input, without giving the name.
0
Good use the filter_input
thus:
filter_input(INPUT_POST, 'nome_input', FILTER_SANITIZE_SPECIAL_CHARS);
I wonder how I can use it in $_POST
for all input, without giving the name.
1
Just get all the field names with the function array_keys
and iterate on them:
foreach(array_keys($_POST) as $var)
{
$filtered[$var] = filter_input(INPUT_POST, $var, FILTER_SANITIZE_SPECIAL_CHARS);
}
In this way, $filtered
will have all the values of $_POST
after passing through the filter.
You can alternatively use the function array_map
:
$filtered = array_map(function ($var) {
return filter_input(INPUT_POST, $var, FILTER_SANITIZE_SPECIAL_CHARS);
}, $_POST);
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Still my netbeans is asked to use the filter on
$_POST
. Following photo for you understand better. http://i.imgur.com/a6ZLZbv.png– Hugo Borges