0
votes

I want my contact form to have an option to choose recipients by the user. Therefore, I implemented the list of 12 checkboxes - each of them is representing the different recipient of the message.

Checkbox value = email adress. Then in php I used the implode function, as some other person adviced me but I can not make it work properly.

I get this error message: "Warning: implode() [function.implode]: Invalid arguments passed in /mywebsite.com/mail.php on line 112"

Line 112 of the code is: $emails = implode(",",$_REQUEST['group1']);

Ok now the html code:

<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="[email protected]">

Now the php code:

$emails = implode(",",$_REQUEST['group1']);
$email_to = $emails;

Guys, any idea what might be wrong here? I will highly appreciate your help. Thanks in advance!

1
change name="group1" to name="group1[]" - Abhik Chakraborty
Post that as an answer so he can accept it. - Barmar
yes please. it works just fine! thank you! - Wuu
ok posted the answer. - Abhik Chakraborty

1 Answers

1
votes

You are using the name of the HTML field as

name="group1"

So to implode() it needs an array so change the above as

name="group1[]"

Do it for all the fields.