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( "account@mail.com", "Form, $body, $message, "From: account@server.com>"); ?> Thanks for the help. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
sanchez77 Posted October 26, 2009 Author Share Posted October 26, 2009 so how do I do that? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
sanchez77 Posted October 26, 2009 Author Share Posted October 26, 2009 got it, thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.