How to get a set of dropdown list values and email it using PHP? -


i have 3 dropdown list - set.

demo page can inspected here : http://goo.gl/vqttym

  1. 1st 1 'destination'
  2. 2nd 1 select guest interest in 'attraction or activity' in 'destination'
  3. 3rd 'available attraction / activity' in 'destination'

created following code:

<div class="multi-field">     <select class="text-one" name="destination[]">         <option selected value="base">please select</option>         <option value="colombo">colombo</option>         <option value="kandy">kandy</option>         <option value="anuradhapura">anuradhapura</option>     </select>     <br />      <select class="text-two" name="attraction_or_activity[]">         <option value="attraction_or_activity">select attractions or activities</option>         <option value="attraction">attraction</option>         <option value="activity">activity</option>     </select>      <select class="populated_attr_or_activity" name="attraction_or_activity_selected[]">         <option value="available_attr_act">available attractions / activities</option>         <!-- here, available options populated -->     </select> </div> 

after guest selected option want , submit form should receive these selections email message follow order.

destination (selected value in 1st drop down list) : attraction/activity (selected value in 2nd drop down list) : selected available attraction/activity (selected value in 3rd drop down list)

this set of dropdown list can added more dynamically clicking add more (add destination) button. using following code email.

<?php if(empty($errors)){ // if errors array empty send mail      $headers  = 'mime-version: 1.0' . "\r\n"; // adding support html type email     $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; // adding support html type email     //print $tourist_name;     $msg = '';     $i = 1;     foreach ($_post['destination'] $key => $val) {         $msg .= ' <strong>' . $i++ . '. destination : </strong>' . $val . ', <strong>attraction/activty : </strong>' . $_post['attraction_or_activity'][$key] . '<br />';     };     $msg .= 'name : ' .$tourist_name.'<br/>';     $msg .= 'e-mail : ' . $tourist_email.'<br/>';     $msg .= 'country : ' .$tourist_country.'<br/>';     mail("myemail@gmail.com","custom tour package",$msg, $headers); } ?> 

as see above using 'destination' , 'attraction_or_activity' array only. email body looks like:


1. destination : colombo, attraction/activity : attraction

2. destination : colombo, attraction/activity : activity

3. destination : kandy, attraction/activity : attraction

name : guest name

e-mail : guestemail@gmail.com

country : guest's country


but how expecting email below:

1. destination : colombo, attraction/activity : attraction selected attraction/activity : ganga ramaya

2. destination : colombo, attraction/activity : activity selected attraction/activity : city tour

3. destination : kandy, attraction/activity : attraction selected attraction/activity : temple tooth

name : guest name

e-mail : guestemail@gmail.com

country : guest's country


how have modify code email expect above?

how can include 3rd dropdown lists value foreach loop?

you need take values of attraction_or_activity_selected did attraction_or_activity. try changing code inside foreach :

foreach ($_post['destination'] $key => $val) {         $msg .= ' <strong>' . $i++ . '. destination : </strong>' . $val                 . ', <strong>attraction/activty : </strong>' . $_post['attraction_or_activity'][$key]                 . ', <strong>selected attraction/activity  : </strong>' . $_post['attraction_or_activity_selected'][$key]                 . '<br />';  } 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -