![]() |
Redirect - pass message to next page - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Redirect - pass message to next page (/showthread.php?tid=78251) |
Redirect - pass message to next page - BFlokstra - 12-22-2020 Not sure if this is in the right place.... I need to perform a redirect after a database action (delete). I have added the folowing line: return redirect()->to('/evenementen/' . url_title($evenement['evenement_naam'], '-', TRUE)); On evenementen/evenement_name I need a specific message to be shown ("The event was succesfully removed"). Is there a specific CI4 way to do this nicely of should I just add a query to the url? (?m=the_message) I'm pretty new to CI in general, coming from php without any frameworks, so forgive me if this is a "stupid" question ;-) RE: Redirect - pass message to next page - includebeer - 12-22-2020 Try adding "with('message')" like this: PHP Code: return redirect() Then in your view, you can output the message like this: PHP Code: <?php if (session('message') !== null) : ?> RE: Redirect - pass message to next page - BFlokstra - 12-25-2020 Thanks! This worked perfectly. And with a little tweaking I even managed to pas along different types of messages (errors and success messages) |