[eluser]meigwilym[/eluser]
You're only using one insert statement:
Code:
public function reportadder()
{
$insert_data = array( ‘rid’ => ‘NULL’,
‘labno’ => $this->input->post(‘labno’),
‘location’ => $this->input->post(‘loca’),
‘date’ => $this->input->post(‘tdate’),
‘name’ => $this->input->post(‘pname’),
‘age’ => $this->input->post(‘ages’),
‘sex’ => $this->input->post(‘sex’),
‘refdoc’ => $this->input->post(‘dselect1’),
‘test’ => $this->input->post(‘tessel’));
// this is the only insert you're doing:
$insert1=$this->db->insert(‘report’, $insert_data);
}
You could improve your code by naming the model 'report' instead of 'database'.
It's usual to have a number of models, each for one table in the database.
In this case I'd suggest something like
Code:
// application/models/report.php
public function add()
{
$insert_data = array( ‘rid’ => ‘NULL’,
‘labno’ => $this->input->post(‘labno’),
‘location’ => $this->input->post(‘loca’),
‘date’ => $this->input->post(‘tdate’),
‘name’ => $this->input->post(‘pname’),
‘age’ => $this->input->post(‘ages’),
‘sex’ => $this->input->post(‘sex’),
‘refdoc’ => $this->input->post(‘dselect1’),
‘test’ => $this->input->post(‘tessel’));
return $this->db->insert(‘report’, $insert_data);
}
Then using it like this:
Code:
public function insertrec()
{
$this->load->model(‘report’);
$this->report->add();
$this->tmain();
}
I'm afraid I don't have the time to explain why you should be passing the data to the model <b>after</b> validation, but please look at the <a href="http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html">Form Validation</a> class.