[eluser]quest13[/eluser]
Thank you very much for your immediate response.I would like to elaborate little more to explain my case further.
I have a function like the one below.It is a simple contact us page.After inserting the data I want to redirect to the main page and display the message as mentioned.
Controller:
function Addcontact(){
$this->form_validation->set_rules('First_and_Last_Name','Name','trim|required|');
$this->form_validation->set_rules('Phone','Phone','trim|required|alpha_dash');
$this->form_validation->set_rules('Email','Email','trim|required|valid_email');
$this->form_validation->set_rules('Message','Message','trim|required|');
if ($this->form_validation->run() == FALSE){
$this->index();// Takes to the home page
}
else {
$data['success']=$this->contactus_model->Insertcontact();
if($data['success']>0){
$this->session->set_flashdata('message', 'Thank you! Your Message Posted Successfully');
redirect('/contactus/index');
}else {
$this->session->set_flashdata('error', 'Error loading form !');
redirect('/contactus/index');
}
}
and In my view page, I did like this :
<span><?php if($this->session->flashdata('message')) {
echo '<div class="message"> ';
echo '<p>'.$this->session->flashdata('message').'</p>';
$this->session->keep_flashdata('message');
echo'</div>';
}?></span>
<br />
<span><?php if($this->session->flashdata('error')) {
echo '<div class="error"> ';
echo '<p>'.$this->session->flashdata('error').'</p>';
$this->session->keep_flashdata('error');
echo'</div>';
}
No message has been displayed. I am getting the following error message
Message: Cannot modify header information - headers already sent by("c:/.....")
Filename: libraries/Session.php
Line Number: 662
Line no 662 is basically about storing cookie information. So I got a doubt that there is something wrong with my cofig settings.
Another question; I don't want to use session at my contact page.In that case, Is it possible to use set_flashdata ?
Thanks