Form Email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alexandros
Forum Newbie
Posts: 1
Joined: Mon May 09, 2005 10:33 am

Form Email

Post by alexandros »

I am attempting to send an email once a user submits a form. This is quite easy at the moment, but now I have set it up so that the email is sent to a different address depending on which checkbox is checked.

For example:

options (user may check one up to all options):

1
2
3
4

1-3 send to different addresses, while 4 sends to the same address as option 1. How do I make it so that this email is not sent twice? The reason I have 1 and 4 is that while the email address is the same, different data is sent depending on which is checked.
dakkonz
Forum Commoner
Posts: 69
Joined: Sat Dec 27, 2003 2:55 am
Location: Asia

Post by dakkonz »

why not you use a switch to check which option is checked. You can declare the email to send for option 1 -3 and for option 4 can be set to default
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

you should look into assigning your checkboxes as an array.

This is only an example :

Code: Select all

1<input type="checkbox" name="var[]" value="1"><br> 
2<input type="checkbox" name="var[]" value="2"><br> 
3<input type="checkbox" name="var[]" value="3"><br> 
4<input type="checkbox" name="var[]" value="4"><br> 
<br>
then, just loop through them

Code: Select all

foreach($_POST['var'] as $bob)
{
   switch($bob)
   {
       case '1':
           //do something
       break;
       case '2':
           //do something
       break;
       case '3':
           //do something
       break;
       case '4':
           //do something
       break;
   }
}
hope this helps.
Post Reply