Seems to be a browser issue, as in firefox it is working fine but not in chrome.
Why is it that when I submit my php form to insert data into a mysql db table, then check the table. I see my newly created row with the data in it and also an extra row with nothing in it?
My controller:
function Admin() {
parent::Controller();
$this->dx_auth->check_uri_permissions();
$this->load->model('alert_model');
$data['rows'] = $this->alert_model->check($num_results=4);
$this->load->view('includes/header', $data);
}
function index() {
$this->load->view('admin/notifications');
$this->load->view('includes/footer');
}
function sendalert() {
$info = array(
'msg_author' => $this->input->post('msg_author'),
'msg_date' => $this->input->post('msg_date'),
'msg_subject' => $this->input->post('msg_subject'),
'msg_content' => $this->input->post('msg_content')
);
$this->send_notification->send($info);
$this->index();
}
My Model:
function send($info) {
$this->db->insert('msg', $info);
return;
}
My View:
<?php echo form_open('admin/sendalert'); ?>
<label for="msg_subject">Subject</label>
<input type="text" name="msg_subject" id="msg_subject" />
<label for="msg_date">Date</label>
<input type="text" name="msg_date" id="msg_date" />
<label for="msg_author">From</label>
<input type="text" name="msg_author" id="msg_author" />
<label for="msg_content">Content</label>
<input type="text" name="msg_conte开发者_如何学编程nt" id="msg_content" />
<input type="submit" value="submit" />
<?php echo form_close(); ?>
Thanks
Try change
$this->index();
to
redirect('admin/index', 'refresh');
Code posted looks good, but maybe the problem is with:
$this->index();
can you post the index() controller function as well?
Also check your logs if there's not a second request send to the server, that for some reason is rewritten to index.php. Most common is a missing image, a nasty one to find is the request for favicon.ico.
精彩评论