Send multiple checkbox values to email?

For example in the form there are checkboxes with several options and select:

 <input type="checkbox" name="ch" id="ch-1" value="val-1">
 <input type="checkbox" name="ch" id="ch-2" value="val-2">
 <input type="checkbox" name="ch" id="ch-3" value="val-3">

 <select name="sel">
 <option value="val-1" selected>val1</option>
 <option value="val-2">val2</option>

In js the usual treatment of the form (not the point):

 url: 'contacts.php',
 type: 'post',
 data: str
}).done(function(msg) { .... }

Is contacts.php:


 define("CONTACT_FORM", ''); 

 $subject = 'Application';

 $ch = stripslashes($_POST['ch']);
 $sel = stripslashes($_POST['sel']);

 $message = '

 <meta content="text/html; charset=utf-8" http-equiv="Content-Type">

 <p>checkbox Value : '.$ch.'</p>
 <p>select Value : '.$sel.'</p>


 $mail = mail(CONTACT_FORM, $subject, $message,
 "MIME-Version: 1.0\r\n"
 ."From: ".$name." <".CONTACT_FORM.">\r\n"
 ."Reply-To: ".$email."\r\n"
 ."Content-type: text/html; charset=UTF-8\r\n");

 echo "OK";

The mail comes only one value of the checkbox and do nothing with the select.

Question: what am I doing wrong in .php file. How can I fix that would come all the values of checkbox and the value of the select (default and selected)?
July 2nd 19 at 17:48
2 answers
July 2nd 19 at 17:50
The first thing we should start is to do print_r($_POST) and see what's there.
Second - the name of the checkboxes must be attributed to ch square brackets[] - evie.Feil6 commented on July 2nd 19 at 17:53
July 2nd 19 at 17:52
Make unique for each checkbox the names, maybe it will solve your problem.
In the POST method is sent name1=value1, name2=value2, name3=value3

Find more questions by tags HTMLPHP