Jump to content

Archived

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

hanlonj

Checking Email Address from Form is Correct Format

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

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
Share on other sites

×

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.