在 CodeIgniter 框架中使用引导通知插入数据后的通知


Notification after the insert of data by using bootstrap notify in CodeIgniter framework

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

这是我的控制器

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>

您可以在"admin/product"中设置会话闪存数据,例如:

在控制器中:

$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 
  };
?>

我希望对您有所帮助。问候!

控制器

   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 
  };
?>