0

我显示的代码是在成功插入记录时弹出警报。问题是即使在刷新页面或转到另一个视图并返回后,此警报仍然存在。请帮忙

控制器

public function insertBrand()
    {
        $this->form_validation->set_rules('brand','Enter Brand','required|is_unique[brand.Bname]',);
        if($this->form_validation->run())
        {
            $data=['Bname'=>$this->input->post('brand')];
            $this->load->model('data_model');
            $this->data_model->insertmodel('brand',$data);
            $this->session->set_flashdata('status','Brand Name successfully inserted');
            redirect(base_url().'Welcome/createbrand','refresh');
            }
        else{
            $this->session->set_flashdata('status','Brand already exists');
            redirect(base_url().'Welcome/createbrand','refresh');       
        }

    }

看法

<div class="panel-body">
    <?php if($this->session->flashdata('status')): ?>
       <div class="alert alert-success">
       <?= $this->session->flashdata('status'); ?>
        </div>
       <?php endif; ?>
<form method="post" action="<?php echo base_url();?>Welcome/insertBrand"name="chngpwd" class="form-horizontal" onSubmit="return valid();">
                                    
4

0 回答 0