Jump to content

Validating an email addy


tcorbeil

Recommended Posts

Found this code on the site:

 

On a small note to email checking:

Recently it is possible to register domains like www.k�che.de

 

This would also mean that the IsEMail() function from "php at easy2sync dot com" would report an email address like "contact@k�che.de" as false.

 

To correct this, use the function below:

 

function IsEMail($e)

{

    if(eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]*

(\.[_a-z0-9-]+)*@[a-z������0-9]+

(-[a-z������0-9]+)*(\.[a-z������0-9-]+)*

(\.[a-z]{2,4})$", $e))

    {

        return TRUE;

    }

    return FALSE;

}

 

not sure if I'm implementing it correctly..

 

do i call as such?

 

$Email = [email protected]

IsEMail ($Email);

 

out of the function above, how would I come out with a marker variable such as $verify = It's good or $verify= It's bad...

Can anyone clarify?

 

Thanks.

...........

...........

..........

function isvalidemail($email){

  if(preg_match("/^[a-zA-Z_]+(\w+)*((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/i",$email)

                    return true;

  else

              return false;

}

 

if(isvalidemail($email)){

echo "This is valid email";

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.