2015-03-30 3 views
0

У меня есть форма, и заполненные значения должны быть отправлены через mail, но у меня есть несколько значений флажка в моей форме. Как отправить их?Как отправить несколько значений флажков на почту

Вот мой код:

<form name="" action="amail.php" method="post" class="wpcf7-form" novalidate> 
       <div style="display: none;"> 
       <input type="hidden" name="_wpcf7" value="219" /> 
       <input type="hidden" name="_wpcf7_version" value="4.1" /> 
       <input type="hidden" name="_wpcf7_locale" value="en_US" /> 
       <input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f219-o1" /> 
       <input type="hidden" name="_wpnonce" value="70d65de13d" /> 
       </div> 
       <h2>Make a Appointment</h2> 
       <p>Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.</p> 
       <div class="form-field"> 
       <h5 class="form-field-title">Cosmetics</h5> 
       <p><span class="wpcf7-form-control-wrap res-services-1"><span class="wpcf7-form-control wpcf7-checkbox"><span class="wpcf7-list-item first"> 
        <label> 
        <input type="checkbox" name="cosmetics" value="Facials" /> 
        &nbsp;<span class="wpcf7-list-item-label">Facials</span></label> 
        </span><span class="wpcf7-list-item"> 
        <label> 
        <input type="checkbox" name="cosmetics" value="Eyebrow &amp; Eyelashes" /> 
        &nbsp;<span class="wpcf7-list-item-label">Eyebrow &amp; Eyelashes</span></label> 
        </span><span class="wpcf7-list-item"> 
        <label> 
        <input type="checkbox" name="cosmetics" value="Microdermabrasion" /> 
        &nbsp;<span class="wpcf7-list-item-label">Microdermabrasion</span></label> 
        </span><span class="wpcf7-list-item last"> 
        <label> 
        <input type="checkbox" name="cosmetics" value="Acne Treatments" /> 
        &nbsp;<span class="wpcf7-list-item-label">Acne Treatments</span></label> 
        </span></span></span> </p> 
       </div> 
       <div class="form-field"> 
       <h5 class="form-field-title">Hairdressing</h5> 
       <p><span class="wpcf7-form-control-wrap res-services-2"><span class="wpcf7-form-control wpcf7-checkbox"><span class="wpcf7-list-item first"> 
        <label> 
        <input type="checkbox" name="hairdressing" value="Wash" /> 
        &nbsp;<span class="wpcf7-list-item-label">Wash</span></label> 
        </span><span class="wpcf7-list-item"> 
        <label> 
        <input type="checkbox" name="hairdressing" value="Cut &amp; Finish" /> 
        &nbsp;<span class="wpcf7-list-item-label">Cut &amp; Finish</span></label> 
        </span><span class="wpcf7-list-item"> 
        <label> 
        <input type="checkbox" name="hairdressing" value="Blow Dries" /> 
        &nbsp;<span class="wpcf7-list-item-label">Blow Dries</span></label> 
        </span><span class="wpcf7-list-item last"> 
        <label> 
        <input type="checkbox" name="hairdressing" value="Hair Colouring &amp; Highlights" /> 
        &nbsp;<span class="wpcf7-list-item-label">Hair Colouring &amp; Highlights</span></label> 
        </span></span></span> </p> 
       </div> 
       <hr class="c-divider"> 
       <div class="wpcf7-response-output wpcf7-display-none"></div> 
       <div class="row"> 
       <div class="col-sm-6"> 
        <div class="form-field"> 
        <label for="res-your-name">Your Name <span>*</span></label> 
        <span class="wpcf7-form-control-wrap res-your-name"> 
        <input type="text" name="name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" id="res-your-name" aria-required="true" aria-invalid="false" /> 
        </span></div> 
        <div class="form-field"> 
        <label for="res-your-email">Your Email Address</label> 
        <span class="wpcf7-form-control-wrap res-your-email"> 
        <input type="email" name="email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-email" id="res-your-email" aria-invalid="false" /> 
        </span></div> 
        <div class="form-field"> 
        <label for="res-your-phone">Your Phone Number</label> 
        <span class="wpcf7-form-control-wrap res-your-phone"> 
        <input type="tel" name="phone" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-tel wpcf7-validates-as-tel" id="res-your-phone" aria-invalid="false" /> 
        </span></div> 
       </div> 
       <div class="col-sm-6"> 
        <div class="form-field"> 
        <label for="res-reservation-date">Preferred Date & Time</label> 
        <div class="row"> 
         <div class="col-sm-6"> 
         <div class="datepicker-input" data-date-format="mm/dd/yy" data-first-day="0"><span class="wpcf7-form-control-wrap res-reservation-date"> 
          <input type="text" name="date" value="" size="40" class="wpcf7-form-control wpcf7-text" id="res-reservation-date" aria-invalid="false" /> 
          </span></div> 
         </div> 
         <div class="col-sm-6"> <span class="wpcf7-form-control-wrap res-reservation-time"> 
         <select name="time" class="wpcf7-form-control wpcf7-select" aria-invalid="false"> 
          <option value="9:00">9:00</option> 
          <option value="9:30">9:30</option> 
          <option value="10:00">10:00</option> 
          <option value="10:30">10:30</option> 
          <option value="11:00">11:00</option> 
          <option value="11:30">11:30</option> 
          <option value="12:00">12:00</option> 
          <option value="12:30">12:30</option> 
          <option value="13:00">13:00</option> 
          <option value="13:30">13:30</option> 
          <option value="14:00">14:00</option> 
          <option value="14:30">14:30</option> 
          <option value="15:00">15:00</option> 
         </select> 
         </span> </div> 
        </div> 
        </div> 
        <div class="form-field"> 
        <label for="res-reservation-note">Note</label> 
        <span class="wpcf7-form-control-wrap res-reservation-note"> 
        <textarea name="note" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea" id="res-reservation-note" aria-invalid="false"></textarea> 
        </span></div> 
        <div class="form-field"> 
        <input type="submit" value="Send" name="submit" class="wpcf7-form-control wpcf7-submit c-button" /> 
        </div> 
       </div> 
       </div> 
      </form> 

    amail.php: 
    <?php 

    $to = "[email protected]"; 
    $subject = 'A new Appointment Enquiry on DiamondShine'; 
    $cosmetics=$_REQUEST['cosmetics']; 
    $hairdressing=$_REQUEST['hairdressing']; 
    $name = $_REQUEST['name']; 
     $email = $_REQUEST['email']; 
    $phone = $_REQUEST['phone']; 
     $date = $_REQUEST['date']; 
    $time=$_REQUEST['time']; 
    $note=$_REQUEST['note']; 





    $message = '<img src=\imagedental\'><br> 
    <b>cosmetics</b>: '.$cosmetics.'<br><br><b>hairdressing</b>: ' 
    .$hairdressing.'<br><br><b>Name</b>: ' 
    .$name.'<br><br><b>Email</b>: ' 
    .$email.'<br><br><b>phone</b>: ' 
    .$phone.'<br><br><b>Date</b>: ' 
    .$date.'<br><br><b>Time</b>: ' 
    .$time.'<br><br><b>Note</b>:'.$note; 
    // To send HTML mail, the Content-type header must be set 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

    // Additional headers 
    //$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; 
    $headers .= 'From: DiamondShine '.$email . "\r\n"; 
    //$headers .= 'Cc: [email protected]' . "\r\n"; 
    //$headers .= 'Bcc: [email protected]' . "\r\n"; 
    $sent = mail($to, $subject, $message, $headers) ; 
    if($sent) 
    { 
    ?> 
    <script type="text/javascript"> 
    alert('Thanks for contacting Us. We will be in touch with you shortly...'); 
    location.href = "contactus.php"; 
    </script> 
    <?php 
    } 
    else 
    {print "We encountered an error sending your mail"; } 


    ?> 

ответ

0

Попробуйте изменить свое имя флажка, как это

cosmetics к cosmetics[] и hairdressing к hairdressing[]

После сообщения значения затем implode флажок ценности

$cosmetics=implode(",",$_REQUEST['cosmetics']); 
$hairdressing=implode(",",$_REQUEST['hairdressing']); 

Здесь вы получите через запятую значение ,

+0

$ cosmetics = implode (",", $ _ REQUEST ['cosmetics']); вот как ты сказал прав ...? –

+0

Да. В точку. @arunkumar – Krishna38

+0

ok .... я сделал это.thank u –

0

Я бы взглянуть here о том, как это сделать. Есть несколько примеров кода, и некоторые возможности позволяют вам справиться с этим.

+0

ОК .... пожалуйста, дайте мне решение ..... здесь мне нужно объединить несколько значений флажков в $ cosmetics, $ hairdressing, если они выбрали два значения –

+0

Я не могу помочь вам, если вы не можете помочь себе. Я направил вас в правильном направлении, чтобы получить решение, которое вы ищете. Если у вас возникли проблемы, отправьте сообщение с этой проблемой, и я постараюсь помочь вам в дальнейшем. –

+0

ok ..... thank u fine –

Смежные вопросы