Welcome Guest, Not a member yet? Register   Sign In
Strange problem with flashdata
#1

[eluser]wakey[/eluser]
Hi,

I am attempting to use flashdata to send back form validation errors to a user when they submit a contact form. I have used this method in previous projects but cannot get it to work this time.

I am using the following code -

Code:
if ($this->form_validation->run() == FALSE)
{
   $this->session->set_flashdata('contact','true');
   $this->session->set_flashdata('valid', validation_errors());
   $this->session->set_flashdata('name', $this->input->post('name', TRUE));
   $this->session->set_flashdata('email', $this->input->post('email', TRUE));
   $this->session->set_flashdata('message', $this->input->post('message', TRUE));
  
   redirect('home/');
}

The only flashdata that I am able to echo after the redirect is 'contact'. If I change -
Code:
$this->session->set_flashdata('valid', validation_errors());

to

Code:
$this->session->set_flashdata('valid', 'error');

I can then echo the word 'error' after the redirect. Does anyone know how I can pass the validation and input data back to the 'home' using flashdata?

Thanks.
#2

[eluser]CroNiX[/eluser]
Try assigning validation_errors() to a variable and then use the variable when setting the flashdata.
#3

[eluser]wakey[/eluser]
Thanks for the suggestion, I tried it but it didn't work.

However, I got thinking and had a play with my htaccess file and it turns out I had missed out this line when removing index.php -

Code:
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt)

and this was causing problems with session data.




Theme © iAndrew 2016 - Forum software by © MyBB