Reputation:
Why this doesn't work:
if(!($data['email'] = filter_var(INPUT_POST,'email',FILTER_SANITIZE_EMAIL)))
{
$errors['email'] = 'Invalid Email.';
}
And this is working:
if(!($data['email'] = filter_input(INPUT_POST,'email',FILTER_SANITIZE_EMAIL)))
{
$errors['email'] = 'Invalid Email.';
}
Difference here is filter_var
and filter_input
and when I hit submit whit filter_var
doesn't submitting the form but with filter_input
is submitted. Also here
filter_input(INPUT_POST,'email',FILTER_SANITIZE_EMAIL))
if I wrote for example some'@email.com
why doesn't remove '
. Is it working this function? I'm a bit confused.
Upvotes: 4
Views: 3745
Reputation: 3308
If you look at arguments filter_var
and filter_input
functions take, you will see why:
filter_var ($value_to_be_filtered, FILTER_TYPE, $options)
VS
filter_input($input_type , $variable_from_input, FILTER_TYPE, $options)
Where $input_type
is one of INPUT_GET
, INPUT_POST
, INPUT_COOKIE
, INPUT_SERVER
, or INPUT_ENV
.
Upvotes: 4