By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,406 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,406 IT Pros & Developers. It's quick & easy.

Using Formmail.php and trying to select multiple recipients

P: n/a
Hi! Total "newbie to programming" here.

I'm using Jack's Formmail.php, code at:
http://www.dtheatre.com/scripts/sour.../formmail.phps

and I'm trying to figure out how I can have it send an identical message to
more than one recipient, based on a checkbox selected by the user who
submits the form.
<input type="checkbox" name="email1" value="recipient1" />Recipient 1
<input type="checkbox" name="email2" value="recipient2" />Recipient 2
<input type="checkbox" name="email3" value="recipient3" />Recipient 3

where "recipient[n]" is stored in the script:

"recipient1" = "em****@email.com"
"recipient2" = "em****@email.com"
"recipient3" = "em****@email.com"

If the user checks recipient1 AND recipient3, it would send the message to
both of the above e-mail addresses.

Is there a script out there that could do this better?
Any help you can give me would be very helpful!

Thanks so much,
Maggie


Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I noticed that Message-ID:
<6h*****************@newssvr30.news.prodigy.com> from Maggie Blue
contained the following:
<input type="checkbox" name="email1" value="recipient1" />Recipient 1
<input type="checkbox" name="email2" value="recipient2" />Recipient 2
<input type="checkbox" name="email3" value="recipient3" />Recipient 3

where "recipient[n]" is stored in the script:

"recipient1" = "em****@email.com"
"recipient2" = "em****@email.com"
"recipient3" = "em****@email.com"


Give the checkboxes the same name
<input type="checkbox" name="email[]" value="recipient1" />Recipient 1
<input type="checkbox" name="email[]" value="recipient2" />Recipient 2
<input type="checkbox" name="email[]" value="recipient3" />Recipient 3

then

$mailto=implode(",",$_POST['email'] );
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Geoff Berrow <bl******@ckdog.co.uk> wrote:
<input type="checkbox" name="email1" value="recipient1" />Recipient 1
<input type="checkbox" name="email2" value="recipient2" />Recipient 2
<input type="checkbox" name="email3" value="recipient3" />Recipient 3

where "recipient[n]" is stored in the script:

"recipient1" = "em****@email.com"
"recipient2" = "em****@email.com"
"recipient3" = "em****@email.com"


Give the checkboxes the same name
<input type="checkbox" name="email[]" value="recipient1" />Recipient 1
<input type="checkbox" name="email[]" value="recipient2" />Recipient 2
<input type="checkbox" name="email[]" value="recipient3" />Recipient 3

then

$mailto=implode(",",$_POST['email'] );


Close but not complete since $_POST['email'] doesn't (and certainly
shouldn't) contain the emailadresses.

To compare the _values_ of $_POST['email'] with the _keys_ in
$recipient:

<input type="checkbox" name="email[]" value="0" />Recipient 0
....
<input type="checkbox" name="email[]" value="N" />Recipient N

$recipient[]="em****@example.com"
....
$recipient[]="em****@example.com"

$mailto="";
foreach(array_intersect(array_keys($recipient),arr ay_values($_POST['email']))
as $val)
{
$mailto.=$recipient[$val].',';
}
$mailto=trim($mailto,',');

Jul 17 '05 #3

P: n/a
I noticed that Message-ID: <42***********************@news6.xs4all.nl>
from Daniel Tryba contained the following:
$mailto=implode(",",$_POST['email'] );


Close but not complete since $_POST['email'] doesn't (and certainly
shouldn't) contain the emailadresses.

It was late, I was in a hurry...and you have to leave some challenge for
the OP. <g>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

P: n/a

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:t2********************************@4ax.com...
I noticed that Message-ID: <42***********************@news6.xs4all.nl>
from Daniel Tryba contained the following:
$mailto=implode(",",$_POST['email'] );


Close but not complete since $_POST['email'] doesn't (and certainly
shouldn't) contain the emailadresses.

It was late, I was in a hurry...and you have to leave some challenge for
the OP. <g>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


Ooo! How mean! Especially since the OP doesn't know how to read any of that
stuff!
Thanks, everyone; I'll try it out this morning.
-- Maggie Blue
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.