繁体   English   中英

CodeIgniter $ this-> input-> post()

[英]CodeIgniter $this->input->post()

我的order_invoice.php中有这个

   enter code here
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">Email to Customer</button>

<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">

  <!-- Modal content-->
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;     </button>

       <form  action="<?php echo base_url() ?>admin/order/email_invoice/"    method="POST" >

    <center> <input 
                               class="form-control"
                               name="email"
                               placeholder="Customer Email Address"

                            type= <?php echo form_input('email',    set_value('email', '')); ?>    /></center>

    </div>
      <div class="modal-footer">
    <a href="<?php echo base_url() ?>admin/order/email_invoice/<?php echo $invoice_info->invoice_no ?>" type="submit"  name="submit"  class="btn btn-info " >Email to Customer</a></div>


    </form>

我在控制器order.php中有这个

   //sender email
        $to = $_POST['email'];
        //subject
        $subject = 'Invoice no:' . $id;
        // set view page
        $view_page = $this->load->view('admin/order/pdf_order_invoice', $data, true);
        $send_email = $this->mail->sendEmail($from, $to, $subject, $view_page);
        if ($send_email) {
            $this->message->custom_success_msg('admin/order/order_invoice/' . $id,
                'Your email has been send successfully!');
        } else {
            $this->message->custom_error_msg('admin/order/order_invoice/' . $id,
                'Sorry unable to send your email!');
        }
    }else{
             $this->message->custom_error_msg('admin/order/order_invoice/' . $id,
            'Sorry unable to send your email, without company email');
    }

当我单击提交时,电子邮件无法发送,但是如果我替换$to = $_POST['email']; to $to = $_POST['email']; to $ to = myemail@gmail.com;`

它能够发送电子邮件。 请帮忙 ...

您正在使用锚来提交(这是行不通的,它将直接转到页面而不提交表单)。 您需要更改此:

<a href="<?php echo base_url() ?>admin/order/email_invoice/<?php echo $invoice_info->invoice_no ?>" type="submit"  name="submit"  class="btn btn-info " >Email to Customer</a>

对此:

<button type="submit" name="submit" class="btn btn-info " >Email to Customer</button>

我强烈建议您先确认电子邮件地址,然后再继续:

//sender email
$to = $_POST['email'];
if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
    show_error("Email was not valid");
}

这可以帮助您确定表单的构造是否正确,还应防止滥用表单。

如果没有错误,则说明$ to包含有效的电子邮件地址。 这并不意味着邮件实际上将被传递。 有很多很多因素决定邮件是否通过。

暂无
暂无

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

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