ok, I revise my code into this:
controllers/caddLatihan.php
<?php
class CaddLatihan extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('form');
}
public function index() {
$this->load->model('modellatihanci');
$data['records'] = $this->modellatihanci->tangkapdb();
$this->load->view('viewlatihan2ci', $data);
}
public function create()
{
$this->load->library('form_validation');
$data['title'] = 'Create content';
$this->form_validation->set_rules('id', 'id', 'required');
$this->form_validation->set_rules('isi', 'isi', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('viewlatihan2ci', $data);
}
else
{
$this->load->model('News_model');
$this->load->view('success');
}
}
}
?>
News_model.php
<?php
class News_model extends CI_Model
{
public $id;
public $isi;
public function __construct()
{
parent::__construct();
}
public function set_news()
{
$this->id = $this->input->post('id');
$this->isi = $this->input->post('isi');
return $this->db->insert('latihan', $this);
}
}
?>
database: ci
table: latihan
id isi
1 contoh latihan pertama
2 contoh latihan kedua
I still do not see the row being added even after I add a new row by filling in the form.