2016-12-08 9 views
0

私はcodeigniterのウェブサイトに予約フォームを持っています。ユーザーブック私は電子メールを持っているが、問題は、私は予約ごとに15のメールを受信して​​いるということです。ユーザーに情報が与えられ、残りが空白の電子メールが1つあります。ここで複数の電子メールをcodeigniterの予約フォームで受け取る

は私のフォームです:

<form method="post" action="<?php echo base_url();?>Booking/booking_mail/<?php echo $row['destination']; ?>/<?php echo $row['fare']; ?>" enctype="multipart/form-data"> 

         <input name="txtname" type="text" class="form-control" required="required" /> 




         <input name="textcel" type="textcel" class="form-control" required="required" /> 


         <input name="txtemail" type="email" class="form-control" name="txtemail" required="required" /> 



        <textarea name="txtmessage" rows="2" cols="20" id="txtmessage" class="form-control" name="txtmessage"> 
</textarea> 


        <input type="submit" name="btnsendmessage" value="Send Message" id="btnsendmessage" class="btn btn-primary" /> 
         </form> 

、ここでは私のコントローラ機能である:

function booking_mail(){ 

     $txtname= $this->input->post('txtname'); 
     $txtcel= $this->input->post('textcel'); 
     $txtemail= $this->input->post('txtemail'); 
     $txtmessage= $this->input->post('txtmessage'); 
     $destination = $this->uri->segment(3); 
     $fare = $this->uri->segment(4); 

      $this->load->library('email'); 
      $this->email->from('turkishairlines.com', $txtname); 
      $this->email->to('[email protected]'); 
      $this->email->subject('Turkish Airline Booking Form'); 

      $this->email->message(
      'Name: '.$txtname.' 
      Cell No: '.$txtcel.' 
      Email: '.$txtemail.' 
      Message: '.$txtmessage.' 
      Destination: '.$destination.' 
      Fare: '.$fare.'' 
     ); 
     $this->email->send(); 

      $this->load->view('thanks'); 

    } 

私を助けてください。

ありがとうございます。

答えて

0

これまでにページをヒットしたときに、このメールが送信されたようです。この問題を回避するには、フォームが転記されているかどうかチェックすることができます。

function booking_mail() 
{ 

    if(isset($_POST['txtemail'])) 
    { 
     $txtname= $this->input->post('txtname'); 
     $txtcel= $this->input->post('textcel'); 
     $txtemail= $this->input->post('txtemail'); 
     $txtmessage= $this->input->post('txtmessage'); 
     $destination = $this->uri->segment(3); 
     $fare = $this->uri->segment(4); 

      $this->load->library('email'); 
      $this->email->from('turkishairlines.com', $txtname); 
      $this->email->to('[email protected]'); 
      $this->email->subject('Turkish Airline Booking Form'); 

      $this->email->message(
      'Name: '.$txtname.' 
      Cell No: '.$txtcel.' 
      Email: '.$txtemail.' 
      Message: '.$txtmessage.' 
      Destination: '.$destination.' 
      Fare: '.$fare.'' 
     ); 
     $this->email->send(); 

      $this->load->view('thanks'); 
    } 
    else 
     die('form is not posted'); 

} 
関連する問題