0

Hi, I am trying to validate email address's on my registration form. Everything works great except for checkdnsrr function. I was wondering can anyone help with this. I never used checkdnsrr before.

Here is the code I'm using:

//set flag that sais pwd is OK
    $pwdOK = true;
    //trim whitespace
    $_POST['pwd'] = trim($_POST['pwd']);
    if (strlen($_POST['pwd']) < 3) {
        $error['pwd_length'] = 'Password must be at least 3 charecters';
        $pwdOK = false;
    }
//validate email
if(!function_exists('checkdnsrr'))
{
    function checkdnsrr($localhost, $recType = '')
    {
     if(!empty($localhost)) {
       if( $recType == '' ) $recType = "MX";
       exec("nslookup -type=$recType $hostName", $result);
       // check each line to find the one that starts with the host
       // name. If it exists then the function succeeded.
       foreach ($result as $line) {
         if(eregi("^$hostName",$line)) {
           return true;
         }
       }
       // otherwise there was no mail handler for the domain
       return false;
     }
     return false;
    }
}

Thanks.

Edited by Nick Evan: Fixed formatting

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by phpDave
0

I haven't used that function myself, but I can tell you that you haven't provided workable arguments here.

function checkdnsrr($localhost, $recType = '')

First of all, the function description can be found here:
http://us3.php.net/manual/en/function.checkdnsrr.php
It checks DNS records. If you are using a localhost, there is no DNS
Secondly, it wants a type, but you have null. it defaults to MX, so:

function checkdnsrr('someRealSiteName.com');

should work.

0

Thanks, I am new to email validation. I was also wondering of other ways to validate emails.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.