Jump to content

PHP Mail


Ell20

Recommended Posts

Hi,

 

I have set up a form on my site to invite users to the site.

I have set it up so there are 3 boxes to put in 3 different email addresses at a time, however I obviously only want to send the message to all 3 if all 3 boxes have an email address in.

 

I have tried using if and elseif to determine which $to statement to use but it dosent seem to be working.

 

Am I doing something wrong?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/82670-php-mail/
Share on other sites

Sorry:

 

if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email1'])))) {
$e1 = escape_data($_POST['email1']);
} else {
$e1 = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>';
}

if (!empty($email2)) {
if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email2'])))) {
$e2 = escape_data($_POST['email2']);
} else {
$e2 = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>';
}
}
if (!empty($email3)) {
if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email3'])))) {
$e3 = escape_data($_POST['email3']);
} else {
$e3 = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>';
}
}

if ($e1) {
$to = "$e1"; }
elseif ($e1 && $e2) {
$to = "$e1, $e2"; }
elseif ($e1 && $e2 && $e3) {
$to = "$e1, $e2, $e3"; }

Link to comment
https://forums.phpfreaks.com/topic/82670-php-mail/#findComment-420449
Share on other sites

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.