Using PHP 4.3.2 I'm wanting to validate email addresses that are entered into a form. There may be one or more adrresses but multiples will be separated by commas ','.
i.e - dbn@acme.com,sam@acme.com
The following code does not work. Any ideas?
Also how to trim spaces out of the entry in case of:
i.e - dbn@acme.com, sam@acme.com
$emails = array($_POST['EmailRecipie
nts']);
for ($i = 0; $i < count($emails); $i++) {
if (!eregi ("^[A-Z0-9._%+-]+@[A-Z0-9.
-]+\.[A-Z]
{2,4}$", $emails[i])) {
ReportAdminError("Email is incorrect - $emails[i]",'Error','repor
t_template
');
exit;
}
}
Thanks in advance,
David
Start Free Trial