Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post

    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.

  • #2
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts
    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.

  • #3
    New Coder
    Join Date
    Feb 2008
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post
    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";
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •