Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP E-mail Verification Function
Old 08-16-2007, 08:38 AM PHP E-mail Verification Function
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Here is a PHP E-mail Verification function I have created.

PHP Code:
function valid_email($email){
if(
eregi("^[a-z1-9._-]{1,63}@[a-z1-9-]{2,63}\.{1}[a-z1-9]{2,4}(\.[a-z1-9]{2,4})*$"$email)) {
return 
true;
} else {
return 
false;
}

Usage:

PHP Code:
// $email = "rich@whatever.com";   VALID
// $email = "galaxian_dude@whatever.com"; VALID
// $email = "galaxian-rich@what-ever.com"; VALID
// $email = "galaxian@what_ever.com"; INVALID
// $email = "galaxian@dude@whatever.com"; INVALID
// $email = "rich123@whatever.co.uk"; VALID
// $email = "rich-123@whatever.com.tw"; VALID
// $email = "rich@asdasd.commmm"; INVALID

if(valid_email($email)) {
 print 
"Valid!";
} else {
print 
"Invalid!";

Feel free to use. This is my first real practice session with regular expressions. If you have any better examples, please post.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 08-16-2007, 08:45 AM Re: PHP E-mail Verification Function
JamieLewis's Avatar
Pretty Much a Big Deal...

Latest Blog Post:
Gooie
Posts: 385
Name: Jamie Lewis
Location: UK
Trades: 0
Very nice, simple and elegant.

Jamie
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
JamieLewis is offline
Reply With Quote
View Public Profile Visit JamieLewis's homepage!
 
Old 08-16-2007, 09:25 AM Re: PHP E-mail Verification Function
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Or perhaps the preg version which is [apparently] faster.

PHP Code:
function valid_email($email){
if(
preg_match("/^[a-z1-9._-]{1,63}@[a-z1-9-]{2,63}\.{1}[a-z1-9]{2,4}(\.[a-z1-9]{2,4})*$/"$email)) {
return 
true;
} else {
return 
false;
}

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 08-17-2007, 07:56 AM Re: PHP E-mail Verification Function
extra.account's Avatar
Average Talker

Posts: 25
Trades: 0
Don't think it'll make a significant difference, the speed that is. If the first once works perfectly, use it!
extra.account is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP E-mail Verification Function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45765 seconds with 12 queries