dnotestine
asked on
How to get a Web POST variable into an array using PHP
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
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
for ($i = 0; $i < count($emails); $i++) {
if (!eregi ("^[A-Z0-9._%+-]+@[A-Z0-9.
ReportAdminError("Email is incorrect - $emails[i]",'Error','repor
exit;
}
}
Thanks in advance,
David
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
MrEne, yours works along the same line as mine but doesn't remove the whitespace as requested.
to remove spaces. hope that works.
$emails = explode ( ',' , $_POST['EmailRecipients'] );
$emails = str_replace(" ", "", $emails );
ASKER
Everyone was so fast it was hard to distribute the points. Sorry if I upset anyone with the point spread.