I was having trouble trying to make this function work for ages. Before, I was doing
if ( !filter_has_var(INPUT_POST, 'email') ) {
code here etc.
}
and this never worked though is the correct format for how the function should be set up. reference
Then after playing about with it trying to make it function, i changed 'email' to '$email' and this did the trick. So, now I'm confused, is this a glitch or is my code at the top incorrect?
You can use:
if (isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
{
//Your Code here for valid email...
}
else
{
//Your Code here for invalid email...
}
Through this example i think you can better understand
if ( !filter_has_var(INPUT_GET, 'email') ) {
echo "Email Not Found";
} else {
echo "Email Found";
}
Output
localhost/nanhe/test.php?email=1 //Email Found
localhost/nanhe/test.php?email //Email Found
http://localhost/nanhe/test.php //Email Not Found
Consider on second example http://localhost/nanhe/test.php
$_GET['email']="info@nanhe.in";
if ( !filter_has_var(INPUT_GET, 'email') ) {
echo "Email Not Found";
} else {
echo "Email Found";
}
But output will be Email Not Found