Welcome Guest, Not a member yet? Register   Sign In
Form messages HOWTO?
#1

[eluser]edwin87[/eluser]
Hello CI,

I'm struggling for a while now with messages that has to be shown after a succesful submit.

So when i fill in a form with a title and some text. I press submit. The model and the controller handles the form. The form has to show a message if a submitted page is succesfully added. How do you do this?

I read something about setting some flash data.

Code:
$this->session->set_flashdata('item', 'value');


Actually i want to show a message for 1 or 2 seconds. After the message i want him to redirect to a defined page.


I'm also workin with jQuery. But i want this to work for both.


So can somebody help me with this?
#2

[eluser]MMacdonald[/eluser]
Following successful form validation on page 1:

Code:
$this->session->set_flashdata('message','Your details have been updated');
redirect('page2', 'refresh');

On page 2:

Code:
echo $this->session->flashdata('message');

//call normal view

Why do you need to redirect with jQuery? Just make the page 2 the one you want the person to end up at. Embed the success message in this page. If you want to it disappear after a couple of seconds, just add a jQuery effect to hide the part of the page that shows the success message. I'll leave someone else to answer that part because I'm not so knowledgeable with jQuery.
#3

[eluser]edwin87[/eluser]
Thanks for your reply.

I can't redirect refresh if i use a ajax submit.

Is there a other solution for this?




Theme © iAndrew 2016 - Forum software by © MyBB