Verifying Email Addresses
Moderator: General Moderators
-
JPlush76
- Forum Regular
- Posts: 819
- Joined: Thu Aug 01, 2002 5:42 pm
- Location: Los Angeles, CA
- Contact:
Verifying Email Addresses
Do you generally as a rule of thumb verify your forms with ereg expression checking or do you actually go out there and verify its a working email address through socket checking?
I've been getting some faulty email addresses lately and I'd like to tighten that up a bit.
I've seen a few posts on here with samples but didn't know if there was a general rule of thumb. thanks!
I've been getting some faulty email addresses lately and I'd like to tighten that up a bit.
I've seen a few posts on here with samples but didn't know if there was a general rule of thumb. thanks!
-
JPlush76
- Forum Regular
- Posts: 819
- Joined: Thu Aug 01, 2002 5:42 pm
- Location: Los Angeles, CA
- Contact:
I was going to start using :
I guess thats not a great checker, but what I've been seeing is alot of:
johnaol.com
or just johm
or john@aol
things like that
Code: Select all
function emailcheck($intext){
$theresults = ereg("^ї^@ ]+@ї^@ ]+\.ї^@ \.]+$", $intext, $trashed);
if($theresults) { $isamatch = "yes"; } else { $isamatch = "no"; }
return $isamatch;
}
if(emailcheck($email) == 'yes'){
echo "EMAIL ADDRESS MATCHED";
} else {
echo "EMAIL NO GOOD";
}johnaol.com
or just johm
or john@aol
things like that
HI !
or may be
/^[A-z0-9_\-]+(\.[A-z0-9_\-]+)*@[A-z0-9_]+((\-|\.)[A-z0-9_]+)*\.[A-z]{2,}$/
or better
/^[A-z0-9_\-]+(([^(\s\"\(\)<>@,;:\\<>\.\[\])]|\.)[A-z0-9_\-]+)*@[A-z0-9_]+((\-|\.)[A-z0-9_]+)*\.[A-z]{2,}$/
?
or may be
/^[A-z0-9_\-]+(\.[A-z0-9_\-]+)*@[A-z0-9_]+((\-|\.)[A-z0-9_]+)*\.[A-z]{2,}$/
or better
/^[A-z0-9_\-]+(([^(\s\"\(\)<>@,;:\\<>\.\[\])]|\.)[A-z0-9_\-]+)*@[A-z0-9_]+((\-|\.)[A-z0-9_]+)*\.[A-z]{2,}$/
?
Last edited by Polar on Fri Aug 09, 2002 5:03 pm, edited 1 time in total.
Rather than returning yes or no use true or false, try this out for size (with whichever regular expression you prefer):
I cut out several unneeded strings there and saved lots of lines 
Code: Select all
function emailcheck($intext){
if(ereg("^ї^@ ]+@ї^@ ]+\.ї^@ \.]+$", $intext, $trashed)) {
return true;
} else {
return false;
}
}
if(emailcheck($email)){
echo "EMAIL ADDRESS MATCHED";
} else {
echo "EMAIL NO GOOD";
}-
JPlush76
- Forum Regular
- Posts: 819
- Joined: Thu Aug 01, 2002 5:42 pm
- Location: Los Angeles, CA
- Contact:
hey matt thanks for the tip!
how would I code the if statement if I wanted to check if emailcheck = false?
how would I code the if statement if I wanted to check if emailcheck = false?
Code: Select all
if(emailcheck($email) == 0){
echo "BAD EMAIL, YOU GO FIX NOW ";
exit;
}Hi !
1. disallowed symbols
"<" , ">" , "(" , ")" , "[" , "]" , "\" , "," , ";" , ":" , "@" , """ and whitespace \s (tab, newline and etc)
it is rule
2. address must start from "A-z0-9_" or "-"
it is rule
3. in first part of address (before @) all allowed symbols othere then "A-z0-9_" and "-" must be followed by "A-z0-9_" or "-"
it is recommendation
4. second part of address (domain after @) must start from "A-z0-9"
it is rule
5. in second part of address there may be only "A-z0-9_" symbols with "." and "-" followed by "A-z0-9"
it is recommendation
6. in the end of addres must be dot with and at least 2 letters
it is a rule

1. disallowed symbols
"<" , ">" , "(" , ")" , "[" , "]" , "\" , "," , ";" , ":" , "@" , """ and whitespace \s (tab, newline and etc)
it is rule
2. address must start from "A-z0-9_" or "-"
it is rule
3. in first part of address (before @) all allowed symbols othere then "A-z0-9_" and "-" must be followed by "A-z0-9_" or "-"
it is recommendation
4. second part of address (domain after @) must start from "A-z0-9"
it is rule
5. in second part of address there may be only "A-z0-9_" symbols with "." and "-" followed by "A-z0-9"
it is recommendation
6. in the end of addres must be dot with and at least 2 letters
it is a rule