hanlonj Posted September 27, 2006 Share Posted September 27, 2006 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?ThanksJohn Link to comment https://forums.phpfreaks.com/topic/22233-checking-email-address-from-form-is-correct-format/ Share on other sites More sharing options...
AndyB Posted September 27, 2006 Share Posted September 27, 2006 [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] Link to comment https://forums.phpfreaks.com/topic/22233-checking-email-address-from-form-is-correct-format/#findComment-99518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.