Jump to content

Singleling out digits.


Foser

Recommended Posts

www.php.net/ereg

 

There are a bunch of email validation functions located in the user comments.

 

irlkersten at gmail dot com

22-Jun-2005 11:54

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

 

Or even from www.php.net/eregi

<?php
//Assuming emails should have any of these combinations
//$str = "aa@a.com";
//$str = "a1@a.com";
//$str = "a.1@a.com";
//$str = "a.1a1@a.com";
//$str = "a1.a1@a.com";
//$str = "a1.a_1@a.com";
//$str = "a1.a-1@a.com";
//$str = "a1.a_1-a@a.com";
//$str = "a1.a_1-a@a-a.com";
$str = "a1.a_1-a@a-a.com.do";
//Anything out of these examples echos wrong
if(eregi("^[a-z]+[a-z0-9_-]*(([.]{1})|([a-z0-9_-]*))[a-z0-9_-]+
[@]{1}[a-z0-9_-]+[.](([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2}))$",$str)) {
       echo "Right<br>";
} else {
   echo "Wrong<br>";
};
//You can enhanced this email validation by adding a list of valid domain name extensions ie.: .com,.net.,.org, ect and country specific ones too ie.: .do,.us,.br,.ve,.es, etc. in this part of the code (([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2}))
?>

 

If thats what you are looking for, no need to re--invent the wheel.

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.