I have problem with array on flashdata codeigniter to send alert, if without framework this code work correcly, I modified this to codeigniter, but it does not work.
Controller Code:
function reply(){
$id = $this->input->post('id');
$err = array();
if(!$_POST['msg']) {
$err[] = 'all the fields must be filled in!';
}
else if(!count($err)){
$data = array(
'DestinationNumber'=> $this->input->post('hp'),
'TextDecoded'=> $this->input->post('msg'),
'i_id'=> $this->input->post('id'));
$this->inbox_model->reply($data);
if($data >= 1) {
$this->session->set_flashdata['msg']['success']='Send Success!';
}
else {
$err[] = 'Send Failed!';
}
}
if(count($err)){
$this->session->set_flashdata['msg']['err'] = implode('<br />',$err);
}
redirect('sms/inbox/read/'.$id);
}
View Code :
if($this->session->flashdata['msg']['err']){
echo "<div class='alert alert-danger alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
".$this->session->flashdata['msg']['err']."</div>";
$this->session->unset_flashdata['msg']['err'];
}
if($this->session->flashdata['msg']['success']){
echo "<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
".$this->session->flashdata['msg']['success']."</div>";
$this->session->unset_flashdata['msg']['success'];
}
Who can help me?