[eluser]joneslee[/eluser]
Hi there,
I am writing a simple login page in which error text will be stored as flashdata. I created a visible div in the presentation page to show that error. What I try to achieve is to check if there is no flashdata then the DIV will be set to style='display:none' else set it to 'visible'. I use the following code:
View:
Code:
if(empty($this->session->flashdata('msg')
$display_string = 'none';
else
$display_string = 'visible';
<div id="loginStatus" style="display: <?= $display ?>">
<code>
<?=$this->session->flashdata('msg');?>
</code>
</div>
I got an error said that cannot return value in a write context page..
Here is my controller:
Controller:
Code:
if ($this->form_validation->run() == false) {
$this->session->set_flashdata('msg', $this->form_validation->error_string('<span>', '</span><br/>'));
$this->session->set_flashdata($_POST);
redirect('home', 'location');
}
Can someone show me how could I check whether the flashdata is yet created or empty in View layer?