I have tried all that I could and finally thought of asking here :
I have a checkbox where multiple values can be checked, in my php I am trying to get those values in a variable like this:
if(!empty($_POST['procedure'])) {
foreach($_POST['procedure'] as $procedure) {
$proc = implode(",", (array)$procedure);
}
echo $proc;
}
Issue 1. Its echoing the last value selected rather than the multiple selected.
In my html email template I have this :
<strong>Which procedure(s) are you inquiring about?</strong>
<p><?php echo $proc; ?></p>
Issue 2. Its not echoing any values here.
For the resolution of issue 1 , I tried the following code :
if(!empty($_POST['procedure'])) {
foreach($_POST['procedure'] as $procedure) {
echo $proc;
}
}
Prints out the values , without comma but still empty values in email.
Also since I am emailing these values echoing the result doesnt make sense , I was trying it for testing purpose only.
Output of $proc as requested :
Vertical Horizontal Flat
These are the values of the checkboxes , and the echo $proc is catching them correctly ..
Update: Mail function Code.
$user_email = addslashes($_POST['email']);
$filter_values = 'form, submit-btn';
$errors = '<p class="alert alert-success">Your message has been successfully sent !</p>';
$options = array(
'from_email' => '',
'from_name' => 'form', // optional
'reply_to' => 'test@test.com', // optional
'adress' => 'my@gmail.com',
'subject' => 'contact',
'attachments' => 'img/wallacegromit.jpg', // optional
'filter_values' => 'form, submit-btn',
'html_template' => '../forms/mailer/email-templates/contact-email.html', // optional
'css_template' => '../forms/mailer/email-templates/contact-email.css', // optional
'sent_message' => '<p class="alert alert-success">Your message has been successfully sent !</p>', // optional
'display_errors' => true // optional, default false
);
$sent_message = Form::sendAdvancedMail($options);
<strong>Which procedure(s) are you inquiring about?</strong>
<p>{proc} </p>
And how in my case?
Update: This is the code which is replacing every posted values for the html email .
$filter = explode(",", $filter_values);
for ($i = 0; $i < count($filter); $i++) {
$filter[$i] = trim(mb_strtolower($filter[$i]));
}
$replacements = array_merge($values, $custom_replacements);
foreach ($replacements as $key => $value) {
if (!in_array(mb_strtolower($key), $filter) && !is_array($value)) {
$html = str_replace('{' . $key . '}', $replacements[$key], $html);
}
}