I am new to PHP and am looking for some help with the following:
I have a large HTML form with various inputs, selects and textareas. On submit I pass all field values to another PHP page to create an email with them.
This works as intended for text inputs, radio buttons, selects, textareas etc. but not for checkboxes.
In the form I have multiple checkboxes that all look as follows using the same name:
<input type='checkbox' class='someClass' id='language1' name='language[]' value='de - German' />
<input type='checkbox' class='someClass' id='language2' name='language[]' value='en - English' />
<input type='checkbox' class='someClass' id='language3' name='language[]' value='fr - French' />
<!-- ... -->
On the PHP side I tried the following but if I then use $languages
for my email body it shows as blank (while all other fields appear correctly):
$languages = implode(',', $_POST['language[]']);
What I am trying to do is to save all values from the $_POST["language"]
array in one variable, separated with commas (and no comma at the end).
Can someone help me with this ?
Many thanks in advance
$_POST['language']
in place of$_POST['language[]']
? – Maximus2012 Jun 19 '15 at 18:58