简体   繁体   中英

php implode contact form issue

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="mail_one@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_two@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_three@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_four@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_five@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_six@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_seven@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_eight@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_nine@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_ten@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_eleven@mywebsite.com">
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="group1" value="mail_twelve@mywebsite.com">

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM