Jump to content

Validating an email addy


tcorbeil

Recommended Posts

And another..

 

I use:

 

if (!@file_get_contents($weblink)){

@header("Location: ".$_SERVER['HTTP_REFERER']);

}

 

where $weblink is equal to a website.. this is to validate a weblink..

 

What would I use to validate an email address?

 

Thanks.

Link to comment
Share on other sites

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 = dsdfsf@sdsgjg.com

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.

Link to comment
Share on other sites

I have modified the code to this:

 

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

    {

        return TRUE;

echo "1";}

 

I don't see the echo come up even though I know it is valid.. any other suggestions?

 

Link to comment
Share on other sites

...........

...........

..........

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";

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.