close ad
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Send mutiple choices checkboxes ?

Thread began 4/28/2014 10:49 am by Hervé | Last modified 5/13/2014 8:16 am by Jason Byrnes | 2086 views | 5 replies |


Send mutiple choices checkboxes ?


In my form i have multiple checkboxes, visitor has to check at least one checkbox.
Sending email only shows one choice not the other.

Here is sending code
$MailAttachments = "";
$MailBCC = "";
$MailCC = "";
$MailTo = "";
$MailBodyFormat = "";
$MailBody = "";
$MailImportance = "";
$MailFrom = "".((isset($_POST["nom"]))?$_POST["nom"]:"") ."";
$MailSubject = "Mes centres d’intérêts ";

//Global Variables

$WA_MailObject = WAUE_Definition("","","","","","");

if ($RecipientEmail) {
$WA_MailObject = WAUE_AddRecipient($WA_MailObject,$RecipientEmail);
else {
//To Entries

//Additional Headers

//Attachment Entries

//BCC Entries

//CC Entries

//Body Format
$WA_MailObject = WAUE_BodyFormat($WA_MailObject,0);

//Set Importance
$WA_MailObject = WAUE_SetImportance($WA_MailObject,"3");

//Start Mail Body
$MailBody = $MailBody . "<html><head></head><body>\r\n";
$MailBody = $MailBody . "\r\n";
$MailBody = $MailBody . "<p>Nom : ";
$MailBody = $MailBody . ((isset($_POST["nom"]))?$_POST["nom"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Prénom : ";
$MailBody = $MailBody . ((isset($_POST["prenom"]))?$_POST["prenom"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Adresse : ";
$MailBody = $MailBody . ((isset($_POST["adresse"]))?$_POST["adresse"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Code Postal : ";
$MailBody = $MailBody . ((isset($_POST["codepostal"]))?$_POST["codepostal"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Localité : ";
$MailBody = $MailBody . ((isset($_POST["localite"]))?$_POST["localite"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Pays : ";
$MailBody = $MailBody . ((isset($_POST["pays"]))?$_POST["pays"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Email : ";
$MailBody = $MailBody . ((isset($_POST["email"]))?$_POST["email"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Mon niveau PNP : ";
$MailBody = $MailBody . ((isset($_POST["niveau"]))?$_POST["niveau"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Mes intérêts :</p>\r\n";
$MailBody = $MailBody . "<p>";
$MailBody = $MailBody . ((isset($_POST["interet_"]))?$_POST["interet_"]:""); ============> HERE is the fist check box item
$MailBody = $MailBody . "<br />\r\n";
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Comment avez-vous connu Ressources : <br />\r\n";
$MailBody = $MailBody . ((isset($_POST["comment"]))?$_POST["comment"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>&nbsp;</p>\r\n";
$MailBody = $MailBody . "</body></html>";
//End Mail Body

Thanks helping me.

Sign in to reply to this post

Jason ByrnesWebAssist

when working with multiple selection checkboxes, the names for them should all be the same and end with [], for example:

<input type="checkbox" name="interet[]" value="Relation d'aide" id="interet_1">

then in the code to write the value in the email, use the implode function to create a comma separated list:

$MailBody = $MailBody . ((isset($_POST["interet"]))?implode(",", $_POST["interet"]):"");

Sign in to reply to this post


Hello Jason,

A little delay in this project but now it's back.
With this syntax $MailBody = $MailBody . ((isset($_POST["interet"]))?implode(",", $_POST["interet"]):""); i don't receive anything in my email and i get some warning mesages :
Warning: implode() [function.implode]: Invalid arguments passed in /home/_pl/pnl/pub/ on line 68

Warning: implode() [function.implode]: Invalid arguments passed in /home/_pl/pnl/pub/ on line 69

Warning: Cannot modify header information - headers already sent by (output started at /home/_pl/pnl/pub/ in /home/_pl/pnl/pub/ on line 99

As you can see i have tested various syntaxes on lines 67, 68, 69 respectively :
$MailBody = $MailBody . "line 67".((isset($_POST["interet"]))? ($_POST["interet"]):"")."";
$MailBody = $MailBody . "line 68".implode("<br/> ",((isset($_POST["interet"]))? ($_POST["interet"]):""))."";
$MailBody = $MailBody . "line 69".((isset($_POST["interet"]))?implode(",", $_POST["interet"]):"");

first syntax (line 67) send in the email line 671 Relation d\'aide, 2 Psychothérapie, 6 Entreprise (complete line email message is Mes intérêts :

line 671 Relation d\'aide, 2 Psychothérapie, 6 Entrepriseline 68line 69) but i want to have linr returns between data like
1 Relation d\'aide
2 Psychothérapie
6 Entreprise

i still have to utf8_decode and stripslashes the string but this is not a problem.

Thanks for you help

Sign in to reply to this post

Jason ByrnesWebAssist

ok, so this code is giving you close to what you want:

$MailBody = $MailBody . "line 67".((isset($_POST["interet"]))? ($_POST["interet"]):"")."";

but you want to replace the commas with line breaks, so change it to:

$MailBody = $MailBody . "line 67".((isset($_POST["interet"]))? str_replace(", ", "<br />", $_POST["interet"]):"")."";

Sign in to reply to this post


Thank you Jason,

I get wath i need now,great !

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...