Jump to content


Photo

Checking Email Address from Form is Correct Format


  • Please log in to reply
1 reply to this topic

#1 hanlonj

hanlonj
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 27 September 2006 - 10:59 AM

Hi,

I want to check that email addresses entered into my form have some letters or numbers before the "@"and then comes a "." and then some letters e.g. ".net" or ".com" etc.

I think I have to use the "ereg" function? Can anyone supply a generic example?

Thanks

John

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 September 2006 - 11:06 AM

    if (!$email) {
        $err.= "Please provide your email address<br/>";
    }
    if ($email) {
        if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
            $err.= $email. " is not a valid email address.<br/>";
        }
    }

Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users