[eluser]mdcode[/eluser]
Hopefully this is the last one from me for a while, but I am having trouble inserting data from a form into a database. When the form is loaded, data filled in and then submitted, the page refreshes with a reset (blank) form and no data has been inserted into the db, even though there are no error messages.
I have checked all field names and corresponding column names in the 'projects' table and confirm them to be correct. I have also gone through several articles here in the forums and on other sites, and through two tutorials out there but still no joy.
CONTROLLER:
Code:
if($this->input->post('submit_form'))
{
$this->projects_model->insert();
}
MODEL:
Code:
/* inserting the project data */
function insert()
{
$data = array(
'customer'=>$this->input->post('customer', TRUE),
'division'=>$this->input->post('division', TRUE),
//'date_raised'=>'CURDATE()',
'date_required'=>$this->input->post('date_required', TRUE),
'tech'=>$this->input->post('tech', TRUE),
'rep'=>$this->input->post('rep', TRUE),
'priority'=>$this->input->post('priority', TRUE),
//'job_status'=>'Not Started',
'allocated_time'=>$this->input->post('allocated_time', TRUE),
);
$this->db->insert('projects',$data);
}
And the VIEW:
Code:
<?php echo form_open('projects/add'); ?>
<?php echo form_fieldset('Main Details'); ?>
<table class="table100">
<tr>
<td width="10%">Customer</td>
<td width="40%"><?php echo form_dropdown('customer', $customers, '', $dds); ?></td>
<td width="10%">Division</td>
<td width="40%"><?php echo form_dropdown('division', $divisions, '', $dds); ?></td>
</tr>
<tr>
<td width="10%">Date Required</td>
<td width="40%"><?php echo form_input($date_required); ?></td>
<td width="10%"> </td>
<td width="40%"> </td>
</tr>
<tr>
<td width="10%">Technician</td>
<td width="40%"><?php echo form_dropdown('tech', $techs, '', $dds); ?></td>
<td width="10%">Representative</td>
<td width="40%"><?php echo form_dropdown('rep', $reps, '', $dds); ?></td>
</tr>
<tr>
<td width="10%">Priority</td>
<td width="40%"><?php echo form_dropdown('priority', $priority, 'Medium'); ?></td>
<td width="10%">Allocated Time</td>
<td width="40%" style="font-weight:normal;"><?php echo form_input($allocated_time); ?> hours</td>
</tr>
</table>
<?php echo form_fieldset_close(); ?>
<?php echo form_submit($submit_form, 'Add Project'); ?>
Any and all help is gratefully received.