Reputation: 321
I tried to input the data and put it into the database , and then redirect it to the front page . but I wanted to give notification to bootstrap notify after the entry database and redirect it to the front page?
This my Controllers
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');
}
This script Bootstrap Notify
<script type="text/javascript">
$(document).ready(function(){
$.notify({
icon: 'fa fa-check-circle',
message: "Success <b>Entry Database</b>."
},{
type: 'info',
timer: 4000
});
});
</script>
Upvotes: 2
Views: 4143
Reputation: 353
Controller
redirect('admin/product/success');
View
<?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
};
?>
Upvotes: 2
Reputation: 312
You can set a session flashdata in "admin/product", for example:
In your controller:
$this->session->set_flashdata('message', 'success');
redirect('admin/product');
And in your admin/product page:
<?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
};
?>
I hope to help you. Regards!
Upvotes: 3