简体   繁体   English

在codeigniter预订表格中收到多封电子邮件

[英]receiving multiple emails in codeigniter booking form

I have a booking form on my codeigniter website. 我在我的codeigniter网站上有一个预订表格。 when the user book i got an email, but the problem is that i am receiving 15 email on per booking. 当用户预订时,我收到一封电子邮件,但问题是每次预订我都会收到15封电子邮件。 I got one email which has the user given information and rest are blank. 我收到一封电子邮件,其中有用户提供的信息,其余为空白。

Here is my form: 这是我的表格:

    <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>

and here is my controller function: 这是我的控制器功能:

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('fantastictravelsuk@gmail.com');
            $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');

    }

Please help me out. 请帮帮我。

Thanks 谢谢

It seems like, when ever you hit page, this send you an email. 看起来,只要您点击页面,就会向您发送电子邮件。 To avoid this issue, you can check form is posted or not. 为避免此问题,您可以检查表单是否已过帐。

Example

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('fantastictravelsuk@gmail.com');
            $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');

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM