[eluser]shinokada[/eluser]
I have a following controller, model and view.
When I refresh a page it sends the same data again.
What am I doing wrong here?
Thanks in advance.
Code:
//Controller
function Welcome()
{
parent::Controller();
$this->load->helper('url');
$this->load->database();
}
function forms(){
$data['header']='input form';
$data['title']='input form';
$this->load->model('MForm');
if ($this->input->post('start_time')){
$this->MForm->enterform();
redirect('welcome/forms', 'refresh');
}else{
$this->load->view('forms',$data);
}
}
// model
function enterform(){
$data = array(
'date' => $this->input->post('date'),
'start_time' => $this->input->post('start_time'),
'finish_time' => $this->input->post('finish_time'),
'instructor' => $this->input->post('instructor'),
);
$this->db->insert('schedules',$data);
}
// view
<form name="form1" method="post" action="forms">
<!-- form 1 -->
<label for='start_time'>1. Start Time</label>
<input type="text" name="start_time" />
<label for='finish_time'>Finish Time</label>
<input type="text" name="finish_time" />
<label for='instructor'>Instructor</label>
<select name="instructor">
<option value="john">John</option>
<option value="mary">Mary</option>
<option value="jim">Jim</option>
</select>
<input type="hidden" name="date" value="<?php echo $date; ?>"/>
<input type="submit" name="submit" value="Submit" />
</form>