I think my algorithm is wrong and I don't know why. Could you please tell my mistake ? Here is the problem : Everytime I refresh my page, it always sends '0' to each field, even I have not filled the form yet.
The controller :
function index() {
$this->load->helper('form');
$this->load->helper('url');
$this->load->helper('html');
$data = array (
'nama' =>$this->input->post('nama'),
'email' =>$this->input->post('email'),
'telepon' =>$this->input->post('telepon'),
'line' =>$this->input->post('line')
);
$this->load->model('site_model');
$this->site_model->add_record($data);
$this->load->view('index');
}
The Model :
class Site_model extends CI_Model {
function add_record($data) {
$this->load->database();
$this->db->insert('tabel_data', $data);
return;
}
}
Some lines from index.php (view) :
<tr>
<td><p><label>Nama</label></p></td>
<td>: <input type="text" name="nama" id="nama" title="Tolong isi nama" autofocus required></td>
Help me, please !! My deadline is so close :D