Let me clearify you in an easy way...
This will be your controller
class Site extends CI_Controller
{
function index()
{
$this->load->view('form.php');// loading form view
}
function insert_to_db()
{
$this->load->model('site_model');
$this->site_model->insert_to_db();
$this->load->view('success');//loading success view
}
}
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();?>index.php/site/insert_into_db" method="post">
Field 1 = <input type = 'text' name='f1'>
Field 2 = <input type = 'text' name='f2'>
Field 3 = <input type = 'text' name='f3'>
<input type='submit'>
</form>
success.php
<b>Your data has been inserted!!!</b>
In your model you need to pull those datas of form and insert into db this way
site_model.php
class Site_model extends CI_Model
{
function insert_into_db()
{
$f1 = $_POST['f1'];
$f2 = $_POST['f2'];
$f3 = $_POST['f3'];
$this->db->query("INSERT INTO tbl_name VALUES('$f1','$f2','$f3')");
}
}
In this case your database has three fields... modify query as per your requirements