2

我尝试输入数据并将其放入数据库,然后将其重定向到首页。但是我想在条目数据库之后向引导程序通知发出通知并将其重定向到首页?

这是我的控制器

function insert() {

    $barcode = $this->input->post('id_barcode');

    $imageResource = Zend_Barcode::factory('code128', 'image', array('text'=>$barcode.date("Ymd")), array())->draw();
    $imageName = $barcode.'.jpg';
    $imagePath = './result/';
        if (!is_dir($imagePath)) {
            mkdir ($imagePath, 777, TRUE);
            }
    imagejpeg($imageResource, $imagePath.$imageName);   

    $this->product_m->insert_produk($imageName);
    redirect('admin/product');  
}

这个脚本引导通知

<script type="text/javascript">
    $(document).ready(function(){


        $.notify({
            icon: 'fa fa-check-circle',
            message: "Success <b>Entry Database</b>."

        },{
            type: 'info',
            timer: 4000
        });

    });
</script>
4

2 回答 2

3

您可以在“admin/product”中设置会话 flashdata,例如:

在您的控制器中:

$this->session->set_flashdata('message', 'success');
redirect('admin/product');

在您的管理员/产品页面中:

<?php 
  $message = $this->session->flashdata('message').
  if($message == "success"){
?>
    <script type="text/javascript">
       $(document).ready(function(){
        $.notify({
            icon: 'fa fa-check-circle',
            message: "Success <b>Entry Database</b>."

        },{
            type: 'info',
            timer: 4000
        });

     });
   </script>
<?php 
  };
?>

我希望能帮助你。问候!

于 2016-03-03T07:03:59.827 回答
2

控制器

   redirect('admin/product/success');  

看法

<?php 
  $check_success = $this->uri->segment(3);
  if($check_success == "success"){
?>
    <script type="text/javascript">
       $(document).ready(function(){
        $.notify({
            icon: 'fa fa-check-circle',
            message: "Success <b>Entry Database</b>."

        },{
            type: 'info',
            timer: 4000
        });

     });
   </script>
<?php 
  };
?>
于 2016-03-03T07:12:12.037 回答