Jump to content

form multi select post


sanchez77

Recommended Posts

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.

 

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.