View Full Version : PHP E-Mail validation
Dynasty
09-08-2002, 02:55 AM
The following bit of code checks if an email in in a standard for as in like name@domain.whatever
$email = <email to check>;
$mail = ".+@.+\..+";
if(eregi($mail,$email))
{
<success code here>
}
else
{
<fail code here>
}
Replacing the bits in the <> with appropriate things of course. Just thought that may be helpful.
-TheDarkEye-
09-08-2002, 03:38 AM
here is how i would do the same thing in coldfusion:
function IsEmail(Email)
{
if (REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$", Email))
{
return TRUE;
}
else
{
return FALSE;
}
}
it uses a regular expression, which is very strict about what it will verify as real email address. you might want to consider converting it to php...
Originally posted by Dynasty
The following bit of code checks if an email in in a standard for as in like name@domain.whatever
$email = <email to check>;
$mail = ".+@.+\..+";
if(eregi($mail,$email))
{
<success code here>
}
else
{
<fail code here>
}
Replacing the bits in the <> with appropriate things of course. Just thought that may be helpful.
could u explain what eregi() function does.thanks:)
-TheDarkEye-
09-08-2002, 04:02 AM
you need to visit php.net. ;)
http://www.php.net/manual/en/function.eregi.php
it is a regualar expression function and it is case-insensitive.
Thanks now I understand:cool:
Dynasty
09-08-2002, 05:12 AM
Regular expressions are evil little things :monkey: :weee:
EnwTheGood
09-08-2002, 07:26 AM
Believe it or not, I'm actually cursed: I've never written a regular expression function that actually worked. I always leave out some little thing or tidbit which seriously screw up whatever I'm trying to do.
For instance, I was taking out all page references, which were in the form (18), in MS Word by doing a Search and Replace with regular expressions. It did the trick, but it also took out every other line break, somehow.
-TheDarkEye-
09-08-2002, 03:55 PM
well, maby you need to read more about them?
EnwTheGood
09-08-2002, 04:31 PM
No, I know most of the stuff. It's just stupid, catastrophic, careless mistakes that get me down.
Frankly, something like ^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3}) looks more like swearing in the Sunday comics than a debuggable, readable language.
Dynasty
09-08-2002, 07:16 PM
Hehe.
-TheDarkEye-
09-09-2002, 01:07 AM
i think its fairly straight forward if you know what all the special characters mean.
what DO they mean?? :eek:
-TheDarkEye-
09-20-2002, 12:28 AM
it would be a major buzz killer if i had to answer you right now. so ill just give you a link:
http://livedocs.macromedia.com/cfmxdocs/Developing_ColdFusion_MX_Applications_with_CFML/regexp3.jsp#1117230
i think that should cover just about all of it.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.