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.
Form Email
Moderator: General Moderators
you should look into assigning your checkboxes as an array.
This is only an example :
then, just loop through them
hope this helps.
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>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;
}
}