![]() |
Multiple forms on the same page [Validation & Session questions] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multiple forms on the same page [Validation & Session questions] (/showthread.php?tid=7892) |
Multiple forms on the same page [Validation & Session questions] - El Forum - 04-26-2008 [eluser]KeyStroke[/eluser] Hi, I've made a "User control panel" page where users have a few fields (each field in a separate form) that allows them to change their user name, password, e-mail and other stuff. I have two questions here: 1) Since my users can change their username, I have to update the session data immediately to reflect that change. I'm storing my session data in a database, not cookies. How do I modify the session data now? 2) I'm seperating my errors messages for my forms individually like this: Code: <?=$this->validation->username_error;?> It keeps telling me that the variable isn't defined if the form isn't submitted. Is there any way to stop this without setting all of my forms' variables in every single routine in my controller? Your help is much appreciated Multiple forms on the same page [Validation & Session questions] - El Forum - 04-26-2008 [eluser]TheFuzzy0ne[/eluser] [quote author="KeyStroke" date="1209232353"]Hi, I've made a "User control panel" page where users have a few fields (each field in a separate form) that allows them to change their user name, password, e-mail and other stuff. I have two questions here: 1) Since my users can change their username, I have to update the session data immediately to reflect that change. I'm storing my session data in a database, not cookies. How do I modify the session data now? [/quote] Maybe you could destroy the session and create another? [quote author="KeyStroke" date="1209232353"] 2) I'm seperating my errors messages for my forms individually like this: Code: <?=$this->validation->username_error;?> It keeps telling me that the variable isn't defined if the form isn't submitted. Is there any way to stop this without setting all of my forms' variables in every single routine in my controller? If it's just a notice/warning and not an error, you should be able to use isset(). Example: Code: <?=(isset($this->validation->username_error)) ? $this->validation->username_error);?> Ugly I know, but it should work. If not, you could just add those undefined variables as hidden fields in your forms, but I wouldn't recommend it. I think my first suggestion should work. |