2016-09-30 27 views
0

我創建了一個樣本表單。提交表單後,所有值都發送到我的電子郵件,但選定的Datepicker值不會發送到電子郵件。Datepicker值不發送到電子郵件在php

<form action="" method="post" enctype="multipart/form-data"> 
 
     <input class="date-picker" name="arrival" id="datepicker"> 
 
      <div class="input-group-addon"><i class="fa fa-calendar"></i></div>  
 
     <input class="date-picker" name="departure" id="datepicker1"/> 
 
      <div class="input-group-addon"><i class="fa fa-calendar"></i></div> 
 
     <div class="col-lg-6 col-md-6"> 
 
                <input type="text" placeholder="First Name *" name="fname" required> 
 
               </div> 
 
               <div class="col-lg-6 col-md-6"> 
 
                <input type="text" placeholder="Last Name *" required name="lname"> 
 
               </div> 
 
    <input type="submit" name="submit" value="submit"> 
 
     </form> 
 
     <?php 
 
     if(isset($_POST['submit'])){ 
 
     $fname = $_POST['fname']; 
 
       $lname = $_POST['lname']; 
 
     $arrival = $_POST['arrival']; 
 
     \t $departure = $_POST['departure']; 
 
     $secretinfo = $_POST['info']; 
 

 
      
 
      
 
      if ($secretinfo == "") 
 
      { 
 
       $myemail = "[email protected]"; 
 
     $emess.= "Arrival: ".$arrival. "\n"; 
 
     \t $emess.= "Departure: ".$departure. "\n"; 
 
     $emess.= "First Name: ".$fname."\n"; 
 
       $emess.= "Last Name: ".$lname."\n"; 
 
     $ehead = "From: ".$email."\r\n"; 
 
       $subj = "Booking Enquiry from ".$fname." ".$lname."!"; 
 
       $mailsend=mail("$myemail","$subj","$emess","$ehead"); 
 
       if($mailsend){ 
 
     echo "success"; 
 
     } 
 
     } 
 
     } 
 
     ?> 
 
     \t \t ?>

如何將日期選擇器值發送到電子郵件。

+0

刪除多餘的空間'NAME =「到來「',沒有找到你的代碼 – devpro

+0

提交按鈕你檢查瞭解決方案。 – devpro

+0

是的,我檢查的名字和最後的ame值發送到電子郵件,但datepicker值不發送到電子郵件 – narendra

回答

1

你只需要從arrival字段中刪除多餘的空格:

<input class="date-picker" name="arrival " id="datepicker" required> 

使用這樣的:

<input class="date-picker" name="arrival" id="datepicker" required> 

name="arrival "這將返回未定義的索引錯誤。

還有一件事,在開發模式下總是使用php error_reporting()而不是生產模式。

我沒有找到你的代碼中的submit按鈕,我希望你在你的應用程序中使用。


更新1:

你需要從mail()

$mailsend=mail("$myemail","$subj","$emess","$ehead"); 

刪除報價應該是:

$mailsend=mail($myemail,$subj,$emess,$ehead);