...

View Full Version : Why does this always returns false



golffor1
07-21-2012, 05:38 AM
function checkEmail($email)
{
//check email format
if (filter_var($email, FILTER_VALIDATE_EMAIL) == $email){
//check if the domain has MX entries
$aux = explode('@',$email);
return checkdnsrr($aux[1],'MX');
}
return false;
}




$email = $_POST['emailAddress'];
//don't worry I am grabbing the e-mail address from a form and can display it
$var = checkEmail($variable);

if (checkEmail($var) == "true")
{
"true";
}
else
{
echo "false";
}

I am using the e-mail address of this@yahoo.com and that returns false
and using the e-mail address of aaa@aaa.com

HDRebel88
07-21-2012, 06:57 AM
function checkEmail($email)
{
//check email format
if (filter_var($email, FILTER_VALIDATE_EMAIL) == $email){
//check if the domain has MX entries
$aux = explode('@',$email);
return checkdnsrr($aux[1],'MX');
}
return false;
}




$email = $_POST['emailAddress'];
//don't worry I am grabbing the e-mail address from a form and can display it
$var = checkEmail($variable);

if (checkEmail($var) == "true")
{
"true";
}
else
{
echo "false";
}

I am using the e-mail address of this@yahoo.com and that returns false
and using the e-mail address of aaa@aaa.com

What is $variable set to? And unless I'm not following correctly, the return false in the function should be wrapped in an else block. Plus there's no echo in your if statement.

golffor1
07-21-2012, 07:03 AM
Okay that was it...i don't know why I didn't catch the no echo at first.

I put that there and it worked just fine. THanks for the help

This is what the code looks like now



$email = $_POST['emailAddress'];
echo $email;
$var = checkEmail($email);
$answer = checkEmail(true);
echo "Here" .$var;

if(checkEmail($email))
{
echo "This is True";
}
else
{
echo "this is false";
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum