[PHP] Multiple mails to be sent from checkbox selection

2002-05-02 Thread Kevin Meredith

Hi there.

Could someone please let me know what is the best way to send multiple mails
to different users collected from a checkbox on the previous page.

There is a page that displays all the available recipients.  A users then
selects which recipients he wants to receive the mail.  Then the next page
should process this and send the mail off.

I am not sure how I should me sending the checkbox name and variables and
then how to actually insert the email addresses using the mail command.  Is
there a better way than using a checkbox?

Thanks
Kevin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Multiple mails to be sent from checkbox selection

2002-05-02 Thread Dan Hardiker

Hi,

 I am not sure how I should me sending the checkbox name and variables
 and then how to actually insert the email addresses using the mail
 command.  Is there a better way than using a checkbox?

If you have a HTML form with a list of email addresses to send to you might
want the code to look something like:

 input type='checkbox' name='sendTo[]' value='[EMAIL PROTECTED]' / User
1br /
 input type='checkbox' name='sendTo[]' value='[EMAIL PROTECTED]' / User
2br /
 input type='checkbox' name='sendTo[]' value='[EMAIL PROTECTED]' / User
3br /

Now in the resulting PHP code (assuming that you're using = PHP v4.1.x and
using METHOD=get in the form) you should find $_GET['sendTo'] is an array
of email addresses they ticked. Just add them as mail headers (you can find
simple instructions on the http://www.php.net/mail page in the user
comments).

If METHOD=post then use $_POST, and if an old version of PHP is being
used then use $HTTP_POST_VARS / $HTTP_GET_VARS.

-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software  Systems Engineer
First Creative Ltd



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Multiple mails to be sent from checkbox selection

2002-05-02 Thread 1LT John W. Holmes

Checkboxes are an easy way to do it.

The value of a checkbox will only be sent if it's checked. If it's not
checked, then that variable isn't even created.

So the easiest way to do it is to use the email address as the value, and
name the checkboxes all the same name with an [] to make it an array.

input type=checkbox value='[EMAIL PROTECTED]' name='emails[]'
input type=checkbox value='[EMAIL PROTECTED]' name='emails[]'

Then, on the page that processes this form, you'll have an $emails[] array
that'll contain all of your email addresses to send to. So you just do this:

$email_string = implode(;,$emails);
mail($email_string,$subject,$message);

If you can't pass the email addreses, directly, then you'll have to pass an
ID that relates to the email addresses. Name your checkboxes as ID[] or
something similar, and then you'll have an array of IDs to send the email
to.

---John Holmes...

- Original Message -
From: Kevin Meredith [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Thursday, May 02, 2002 10:02 AM
Subject: [PHP] Multiple mails to be sent from checkbox selection


 Hi there.

 Could someone please let me know what is the best way to send multiple
mails
 to different users collected from a checkbox on the previous page.

 There is a page that displays all the available recipients.  A users then
 selects which recipients he wants to receive the mail.  Then the next page
 should process this and send the mail off.

 I am not sure how I should me sending the checkbox name and variables and
 then how to actually insert the email addresses using the mail command.
Is
 there a better way than using a checkbox?

 Thanks
 Kevin


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php