PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dwfait
Forum Contributor
Posts: 113 Joined: Sun Aug 01, 2004 10:36 pm
Post
by dwfait » Thu Aug 05, 2004 12:20 am
Hi. How would i check to see if an email was in the right format?
for example, check to see if a string was *@*.*
where * could be anything.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Aug 05, 2004 12:31 am
search the forums.. we've talked about this ad nauseum.
LiquidPro
Forum Commoner
Posts: 37 Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH
Post
by LiquidPro » Thu Aug 05, 2004 1:24 am
I believe you have to use preg_match...
Try this...
Code: Select all
function check_email($email) {
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) {
return true;
} else {
return false;
}
}
Last edited by
LiquidPro on Thu Aug 05, 2004 1:44 am, edited 2 times in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Aug 05, 2004 1:37 am
Hate to nitpick but, last I checked, a space wasn't allowed in a domain name, and dots could appear anywhere leading up to the @.. missing underscores in domain name too. Might potentially need allowance for ip addresses as the domain too.
LiquidPro
Forum Commoner
Posts: 37 Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH
Post
by LiquidPro » Thu Aug 05, 2004 1:41 am
That's true, I'll have to fix that. And don't worry about nitpicking... programming has to be nitpicked or it won't work, haha.
What do you think about that one? It doesn't have ip address support though.