Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 05-01-2003, 06:57 PM   #1
Member (7 bit)
 
Join Date: Jan 2002
Location: Barcelona
Posts: 85
e-mail validation in php?

I'm trying to validate my registration form but this script for the e-mail validity is returning an error. Can anyone tell me why? Or suggest another piece of code to check an e-mail address. In the meanwhile I've commented it out but I'd like to know a better solution.
Thanks.

/* // check an email address is possibly valid
else (!(preg_match("/^.{2,}?@.{2,}\./", $_POST['email'])))
{
include 'emailInvalid.htm';
} */
craigtaylor74 is offline   Reply With Quote
Old 05-01-2003, 08:44 PM   #2
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
This is the one that I usually use:
PHP Code:
 function is_email_valid($email) { 
  if(
eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$"$email)) return TRUE
  else return 
FALSE

Looking at your code, you should have an if instead of an else.
mairving is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:58 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2