Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-21-2012, 04:38 AM   PM User | #1
golffor1
New Coder

 
Join Date: Feb 2008
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
golffor1 is an unknown quantity at this point
Why does this always returns false

PHP Code:
function checkEmail($email)
{
    
//check email format
    
if (filter_var($emailFILTER_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

Last edited by golffor1; 07-21-2012 at 05:52 AM..
golffor1 is offline   Reply With Quote
Old 07-21-2012, 05:57 AM   PM User | #2
HDRebel88
Regular Coder

 
Join Date: May 2011
Posts: 112
Thanks: 11
Thanked 5 Times in 5 Posts
HDRebel88 is an unknown quantity at this point
Quote:
Originally Posted by golffor1 View Post
PHP Code:
function checkEmail($email)
{
    
//check email format
    
if (filter_var($emailFILTER_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.

Last edited by HDRebel88; 07-21-2012 at 06:00 AM..
HDRebel88 is offline   Reply With Quote
Old 07-21-2012, 06:03 AM   PM User | #3
golffor1
New Coder

 
Join Date: Feb 2008
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
golffor1 is an unknown quantity at this point
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

Code:
$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";
}
golffor1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 PM.


Advertisement
Log in to turn off these ads.