Form - 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 (/showthread.php?tid=59548) |
Form - El Forum - 10-19-2013 [eluser]davy_yg[/eluser] controllers/ccontactus.php Code: <?php routes.php Code: $route['contactus'] = 'ccontactus'; views/contactus.php Code: <div id="title">Your Message: </div><br><br> RESULT: Fatal error: Call to undefined function form_open() in C:\xampp\htdocs\IndonusaCI\application\views\contactus.php on line 72 line 72: <?php echo form_open('ccontactus/contact', array('id'=>'contactform')); I wonder why? Form - El Forum - 10-19-2013 [eluser]davidMC1982[/eluser] Because you're only loading the form helper after the form passes validation which is "after the horse has bolted" so to speak. Load the helper in the constructor or, if you'll be using forms most of the time, autoload it. Form - El Forum - 10-19-2013 [eluser]davy_yg[/eluser] Thanks. At least it shows the form now. Another error after I add this code: Code: <?php A PHP Error was encountered Severity: Notice Message: Undefined index: name Filename: helpers/form_helper.php Line Number: 264 Why is it? Form - El Forum - 10-19-2013 [eluser]Tpojka[/eluser] What is page.php? Form - El Forum - 10-19-2013 [eluser]davidMC1982[/eluser] [quote author="davy_yg" date="1382193408"] Thanks. At least it shows the form now. Another error after I add this code: A PHP Error was encountered Severity: Notice Message: Undefined index: name Filename: helpers/form_helper.php Line Number: 264 Why is it?[/quote] I'm guessing the form helper requires a name attribute and you didn't define one. Form - El Forum - 10-19-2013 [eluser]CroNiX[/eluser] In your contact method, you are setting validation rules for a field named "name", but in your form you have the field named "username". So when you submit your form there is no field named "name" which the validation library is expecting. Form - El Forum - 10-19-2013 [eluser]davy_yg[/eluser] I fixed my view/contactus.php to this: Code: <div id="title">Your Message: </div><br><br> I autoload my form helper: autoload.php Code: $autoload['helper'] = array('url', 'form'); I still have these two errors: A PHP Error was encountered Severity: Notice Message: Undefined index: name Filename: helpers/form_helper.php Line Number: 264 A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: helpers/form_helper.php Line Number: 450 why is it? Form - El Forum - 10-20-2013 [eluser]Tpojka[/eluser] First error you should solve with adding name parameter to your textarea dataMessage array. It would be good to add name parameter to every input field. Second error is indicated because you are using invalid parameters for submit form. As I can see you would like to use form button instead. Form - El Forum - 10-20-2013 [eluser]davidMC1982[/eluser] As I said, you haven't defined "name" in $dataEmail, $dataSubject or $dataMessage. eg Code: $dataMessage = array( |