Form to email: passing success / fail message back to view - howto? - 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: Form to email: passing success / fail message back to view - howto? (/showthread.php?tid=6609) |
Form to email: passing success / fail message back to view - howto? - El Forum - 03-05-2008 [eluser]stef25[/eluser] im making a simple microsite where people fill in a form to recommend company x to their friends. i have one view (index.php) and one controller (mailer.php). the form submits to the page it's on. the view after the submission should be exactly the same, apart from one little <p>success or fail message</p>. Im a bit stuck as to how i can get this message back to the view. I read alot about the use of this->load->vars, but how do i get this to appear in my view? $feedback doesnt exist unless the message sending is success or fail, so when i first arrive at index.php i get an error " Undefined variable: feedback", referring to my echo $feedback. anyone? Code: //send mail + success / fail message Form to email: passing success / fail message back to view - howto? - El Forum - 03-05-2008 [eluser]rweston[/eluser] Code: if(!isset($feedback)) $feedback = ''; What you were trying to do? or : Code: //send mail + success / fail message Form to email: passing success / fail message back to view - howto? - El Forum - 03-05-2008 [eluser]stef25[/eluser] i now have code below in my view, but it always stays at 'hi!'. with my code in the OP, should the success / fail msg get carried back to the view? Code: if(!isset($feedback)) $feedback = 'hi!'; Form to email: passing success / fail message back to view - howto? - El Forum - 03-05-2008 [eluser]rweston[/eluser] stef, from the other thread, i swapped some stuff around. e.g. the loading of the view after the check for the posted data and added a 'definition' for $feedback. I'm fairly 'new' to working with CI, but i've stuck with passing data to the view using the 2nd paramater of the view method ( $this -> load -> view ('viewname', $data) ), but i'll have to check out the load -> vars method and get familar with it. Code: class Mailer extends Controller { Form to email: passing success / fail message back to view - howto? - El Forum - 03-05-2008 [eluser]Michael Wales[/eluser] Not sure why you are using load vars in this instance... here's how I would accomplish the same: Code: $this->data->feedback = 'hi!'; View: Code: echo $feedback; |