Welcome Guest, Not a member yet? Register   Sign In
Redirecting and setting flash message,..
#3

[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>&lt;?php if($this->session->flashdata('message')) {
echo '<div class="message"> ';
echo '<p>'.$this->session->flashdata('message').'</p>';

$this->session->keep_flashdata('message');

echo'</div>';
}?&gt;</span>

<br />

<span>&lt;?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


Messages In This Thread
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 01:13 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 01:54 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 02:50 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 02:56 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 03:44 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 04:49 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 05:15 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 05:40 AM
Redirecting and setting flash message,.. - by El Forum - 06-27-2009, 08:47 AM
Redirecting and setting flash message,.. - by El Forum - 06-28-2009, 10:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB