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 = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
//$str = "[email protected]";
$str = "[email protected]";
//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
https://forums.phpfreaks.com/topic/59098-singleling-out-digits/#findComment-293452
Share on other sites

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.