Jump to content

multiple select options to email


refael

Recommended Posts

 

Hi I hope somone can just help me bring this to work.

 

In a web form i added a multiple select option like so:

 

<select name="product[]" multiple="multiple"

...>

 

in the php file that sends the info to my email i simply added this:

 

$product = $_POST['product'];

 

to the $body i simply added $product

 

$body = " Name - $ime \n \n \n Business - $business \n \n \n Email Address - $email \n \n \n Print Product(s) - $products.[] \n \n \n  Budget - $budget \n \n \n Comment - $comment \n \n \n IP - $ip";

 

that obviously does not work. i am sure i need to loop in an array but have no idea how to so i added this:

 

$products = array(
'product1' => 'product1',
'product2' => 'product2',
................
);

 

what's next? can someone help me PLEASE?

Link to comment
https://forums.phpfreaks.com/topic/179900-multiple-select-options-to-email/
Share on other sites

concatenate a string.

$products = "";
foreach($_POST['product'] as $product) 
{
$products .= $products . " ";
}

 

that will put your products in a line with each one seperated by a space, IE

shirt pants dog cat sandwhich.

 

you could then use the $products variable in your body

mikesta707 i really do thank you but it does not work!

 

let me just repeat ok?

 

in the form i have this: select name="product[]" multiple="multiple" size="10" 

in the mail php i have this:

 

$product = $_POST['product'];

 

$products = array(

'prod1' => 'prod1',

'prod2' => 'prod2'

);

 

$products = "";

foreach($_POST['product'] as $product)

{

$products .= $products . " ";

}

 

$body = $products (this should print the products selected in the email)

 

thanks!!!!

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.