Re: Validating Email Conditional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You added or lost a parenthesis somewhere in there...

if (getmxrr($domaintld,$mxrecords))

That part right there finishes off the "if (test)" part.

Then you've got && starting off the statement where you are sort of
supposed to be doing something more like $valid = true; or have { }

On Wed, August 1, 2007 2:26 pm, CK wrote:
> Hi,
>
> My script is working, but valid returns true even if the user is
> bogus. What needs changing so both conditions have to match, the
> following attempt returned "unexpected logical...."
>
>   if (getmxrr($domaintld,$mxrecords)) && if(fsockopen($domaintld,25,
> $errno,$errstr,30)) {
>           $valid = true;
> 		 }
>
>
>
>
> The following works, but needs the conditional mentioned...
>
> <?php
> $email = "lotus@xxxxxxxxxxxxxxx";
> $valid="";
>
> function validate_email($email)
>
>
> {
>
>     // Create the syntax of email with validation regular expression
>     $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]
> +)*(\.[a-z]{2,4})$";
>
>     // Presume that the email is invalid
>     $valid = false;
>
>     // Validate the syntax
>     if (eregi($regexp, $email))
>     {
>        list($username,$domaintld) = split("@",$email);
>        // Validate the domain
>        if (getmxrr($domaintld,$mxrecords))
>           $valid = true;
> 		 }
> 	// attempts a socket connection to mail server
>    if(fsockopen($domaintld,25,$errno,$errstr,30)) {
> 		$valid = true;
>     } else {
>        	$valid = false;
>    }
> 	 return $valid;
> }
>
> if (validate_email($email))
>     echo "Email is valid!";
> else
>     echo "Email is invalid!";
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux