RE: [PHP] email certain people

From: Date: Fri, 10 Oct 2003 02:42:19 +0000
Subject: RE: [PHP] email certain people
Groups: php.general 
Request: Send a blank email to php-general+get-165689@lists.php.net to get a copy of this message
I forgot to mention that I want the email addresses to be appear on the webpage from a mySQL database. I already have the emails entered into a database, and I have written the page that grabs each email from the database and puts it into a form with the Checkbox. My problem is figuring out how to write the script to email these dynamic addresses. I don't want to hard-code them into the web page. If you need an example or the website, then I can send it to you so you can see. -----Original Message----- From: Andrew Whyte [mailto:a.whyte@cqu.edu.au] Sent: Thu 10/9/2003 10:38 PM To: php-general@lists.php.net Cc: Subject: RE: [PHP] email certain people > -----Original Message----- > From: Davy Campano [mailto:dcampano@leeuniversity.edu] > > I am making a webpage, and I want to be able to email certain > people that are selected by a checkbox when I click the > submit button. I am trying to figure out what the best way > is to do this. There are four people on the page and they > each start with their name checked (so they should receive an > email when I click submit). How would I go writing a script > to check if these "checkboxes" are marked and then emailing > each person??? Thanks for any help! Davy, Something along the lines of: Your form items would be: <INPUT TYPE="CHECKBOX" NAME="EMAIL[]" VALUE="user1@email.com"> user1 @ email.com <BR> <INPUT TYPE="CHECKBOX" NAME="EMAIL[]" VALUE="user2@email.com"> user2 @ email.com <BR> <INPUT TYPE="CHECKBOX" NAME="EMAIL[]" VALUE="user3@email.com"> user3 @ email.com <BR> Then in PHP this get posted to, something like: if ( is_array($_POST["EMAIL"]) ) { // Loop through each... foreach ($_POST["EMAIL"] as $key => $email_addr ) { // send your email to each user... } } This way you can simply add more email input fields to the form over time and the code will always work with it... I'll leave the email sending as an exercise for the reader, there are ample good examples on php.net's doco about this. Cheers, Andrew -- Andrew Whyte Ph: +61 7 4930 9838 Corporate Systems Administrator Fx: +61 7 4930 9254 Information Technology Division Em: a.whyte@cqu.edu.au Central Queensland University, Rockhampton, Qld, 4702 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#165689) next »