I have a delete button which deletes from the database. I press the delete button on my page and it will not do anything until I press it for a couple of times. Sometimes, it just deletes the value from database in one try, other times, I have to keep pressing the delete button a cuple of times for it to delete. Any way to get over this?
My view file:
//other code above
<?php $encrypted = $this->encrypt->encode($data->pid); ?>
<a href="<?php echo base_url() . "profile/delete_entry/" . $encrypted; ?>">Delete</a>
//other code below
My controller:
$this->load->model('model_entry');
$pid = $this->uri->segment(3);
$result = $this->model_entry->entry_delete($pid);
//redirect to entries index.php
My Model
public function entry_delete($pid) {
$pid = $this->encrypt->decode($pid); //to decode
$uid=$this->session->userdata('uid');
$whereConditions = array('pid' => $pid, 'uid' => $uid);
$this->db->where($whereConditions);
$this->db->delete('dayone_entries');
}