Jump to content

Checking Email Address from Form is Correct Format


hanlonj

Recommended Posts

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
[code]    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/>";
        }
    } [/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.