Step1 This will be your controller.
<?php
class Site extends CI_Controller
{
function index()
{
$this->load->view(‘form.php’);// loading form view
}
function insert()
{
$this->load->model(‘site_model’);
$this->site_model->insert();
$this->load->view(‘success.php’);//loading success view
}
}
Step 2 This will be your views. Befor creating views go to autoload.php and autoload url helper and database class. In your config.php set config['base_url'] = “path to your site”; form.php
<form action=”<?php echo base_url();?>Site/insert” method=”post”>
Field 1 <input type = ‘text’ name=’f1′><br>
Field 2 <input type = ‘text’ name=’f2′><br>
Field 3 <input type = ‘text’ name=’f3′><br>
<input type=’submit’>
</form>
Step 3 success.php
<b>Your data has been inserted!!!</b>
Step 4 In your model you need to pull those datas of form and insert into db this way
site_model.php
<?php
class Site_model extends CI_Model
{
function insert()
{
$f1 = $_POST['f1'];
$f2 = $_POST['f2'];
$f3 = $_POST['f3'];
$this->db->query(“INSERT INTO tbl_name VALUES(‘$f1′,’$f2′,’$f3′)”);
}
}
There must be some problem with your configuration…. To use the process above please set the following settings…. In your application/config/autoload.php => $autoload['libraries'] = array(‘database’); $autoload['helper'] = array(‘url’); If you have not used htaccess or route files then in URL place the full URL.