I cannot delete using a button in a datatabe but I can delete if I use a form and I don't know what I'm doing wrong.
The form that works:
<?php echo form_open('/posts/delete/'.$post['id']); ?>
<input type="submit" value="Delete" class="btn btn-danger">
<?php echo form_close(); ?>
MY controller:
public function delete($id){
$this->post_model->delete_post($id);
redirect('posts/latest_post');
}
My model:
public function delete_post($id){
$this->db->where('id', $id);
$this->db->delete('posts');
return true;
}
My button in the datatable:
<td>
<a class="btn btn-danger" type="button" href="<?php echo base_url(); ?>posts/delete/<?php echo $post['id']; ?>"><i class="fa fa-close"></i>delete</a>
</td>
Any help will be appreciated
Thanks
The form that works:
<?php echo form_open('/posts/delete/'.$post['id']); ?>
<input type="submit" value="Delete" class="btn btn-danger">
<?php echo form_close(); ?>
MY controller:
public function delete($id){
$this->post_model->delete_post($id);
redirect('posts/latest_post');
}
My model:
public function delete_post($id){
$this->db->where('id', $id);
$this->db->delete('posts');
return true;
}
My button in the datatable:
<td>
<a class="btn btn-danger" type="button" href="<?php echo base_url(); ?>posts/delete/<?php echo $post['id']; ?>"><i class="fa fa-close"></i>delete</a>
</td>
Any help will be appreciated
Thanks