I am creating a basic web form. I am having trouble with the multiple select box. Here is my html code:
<select multiple="multiple" name="specialties[]">
<option value="Item 1">Item 1</option>
<option value="Item 2">Item 2</option>
<option value="Item 3">Item 3</option>
<option value="Item 3">Item 4</option>
</select>
I am having the form email the results on the PHP side once it's submitted. I know it's a little more involved than $specialties = $_POST['specialties'];
Since this is an array, I can't seem to get it to email the results. I know my form and email results work, it's just this variable. Any help is greatly appreciated.
Try imploding the Array to create a comma separated string:
$specialties = Trim(stripslashes(implode(",", $_POST['specialties'])));
<select multiple="multiple" name="specialties[]">
<option value="Item 1">Item 1</option>
<option value="Item 2">Item 2</option>
<option value="Item 3">Item 3</option>
<option value="Item 3">Item 4</option>
</select>
and your post
foreach ($_POST['specialties'] as $selectedOption)
echo $selectedOption."
";
Does this work?