sanchez77 Posted October 26, 2009 Share Posted October 26, 2009 So I have a an HTML form with a list box that allows mulitple selections. How do I mail all the selections? My form: <select name="Services" size="4" multiple id="Services"> <option value="option1">option1</option> <option value="option2">option2</option> <option value="option3">option3</option> <option value="option4">option4</option> </select> PHP Code $post_Services = $_POST["Services"]; $body .= "Services: ".$post_Services."\n"; mail( "[email protected]", "Form, $body, $message, "From: [email protected]>"); ?> Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/179106-form-multi-select-post/ Share on other sites More sharing options...
akitchin Posted October 26, 2009 Share Posted October 26, 2009 i believe that a select element with multiple option selections will return an array. in that case, if you want to send an individual e-mail for each address, you'll need to loop through $_POST['Services'] with a foreach() loop. if you want to send one bulk e-mail with a length header To: or CC: field, you can either construct that list using a foreach() loop or the implode function. Link to comment https://forums.phpfreaks.com/topic/179106-form-multi-select-post/#findComment-944991 Share on other sites More sharing options...
sanchez77 Posted October 26, 2009 Author Share Posted October 26, 2009 so how do I do that? Link to comment https://forums.phpfreaks.com/topic/179106-form-multi-select-post/#findComment-945001 Share on other sites More sharing options...
sanchez77 Posted October 26, 2009 Author Share Posted October 26, 2009 I want to send the selected values in an email. For example: Services: Option 2, Option 3. Link to comment https://forums.phpfreaks.com/topic/179106-form-multi-select-post/#findComment-945010 Share on other sites More sharing options...
akitchin Posted October 26, 2009 Share Posted October 26, 2009 handling arrays is actually a rather basic concept, and one that would be good to familiarize yourself with. here's a good section in the PHP manual on how to deal with arrays in PHP: http://us2.php.net/manual/en/language.types.array.php have a read-through of that, play around, and come back if you run into any problems implementing the code. this is really the sort of thing you're best off tinkering with yourself. Link to comment https://forums.phpfreaks.com/topic/179106-form-multi-select-post/#findComment-945022 Share on other sites More sharing options...
sanchez77 Posted October 26, 2009 Author Share Posted October 26, 2009 got it, thanks Link to comment https://forums.phpfreaks.com/topic/179106-form-multi-select-post/#findComment-945039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.