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.
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.