Fatal error: Call to undefined function form_open() in c

Posted on

Fatal error: Call to undefined function form_open() in c – Here in this article, we will share some of the most common and frequently asked about PHP problem in programming with detailed answers and code samples. There’s nothing quite so frustrating as being faced with PHP errors and being unable to figure out what is preventing your website from functioning as it should like php and codeigniter . If you have an existing PHP-based website or application that is experiencing performance issues, let’s get thinking about Fatal error: Call to undefined function form_open() in c.

i got this error and daunt know where i went wrong i am new to codeigniter so i am sure its something stupid can anyone figure this out tnx in advance.

create_view.php

     <body>
        <?php echo form_open('create'); ?>
        <ul id="accordion">
 <li>
   <a>Survey Creation</a>
     <ul id="survay">  
       <li>Enter a question:<?php echo form_input('Question')?></li>
       <li>Answer A: <?php echo form_input('qA' );?></li>
       <li>Answer B: <?php echo form_input('qB' );?></li>
       <li>Answer C: <?php echo form_input('qC' );?></li>
       <li><?php echo form_submit('submit', 'Set This Question' );?></li>
      </ul>  
  </li>

create.php

 <?php

class Create extends CI_Controller{

    function index(){

        $this->load->view('create_view');
    }
    // insert data
    function create1()
    {   
     $data = array(
         'Question' => $this->input->post('Question'),
         'qA' => $this->input->post('qA'),
         'qB' => $this->input->post('qB'),
         'qC' => $this->input->post('qC'),


         );


          $this->create_model->add_record($data);
          $this->home();

    }



 }

?>

Solution :

Seems like you forgot to load the form helper. Use the application/config/autoload.php or add the following line into your controller before loading the view:

$this->load->helper('form');

You may also load this helpers on all controllers.
Go your config folder and open autoload.php in any editor and then load required helper as following :

$autoload['helper'] = array('url','form');

Load your CI helper in your controller
$this->load->helper(‘form’);

class Create extends CI_Controller{

    function index(){

        $this->load->view('create_view');
        $this->load->helper('form');

or make auto load helpers on all contollers. Open application/config/autoload.php

        $autoload['helpers'] = array('form','myhelper');

You need to load Helper ‘Form’ before using this function.
Add this line:

$this->load->helper('form');

Make sure to have following line above view called in controller:

$this->load->library('form_validation'); //make sure to have it, before view call 

$this->load->view('profile');

Leave a Reply

Your email address will not be published. Required fields are marked *