我有一个删除按钮,可以从数据库中删除。我按下页面上的删除按钮,它不会做任何事情,直到我按下它几次。有时,它只是一次删除数据库中的值,其他时候,我必须按delete按钮三次才能删除它。有没有办法克服这一点?
我的视图文件:
//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我的控制器:
$this->load->model('model_entry');
    $pid = $this->uri->segment(3);
    $result = $this->model_entry->entry_delete($pid);
    //redirect to entries index.php我的模型
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');
}发布于 2015-03-05 05:41:21
不确定是否可以在URL中放置加密数据。Codeigniter不允许您使用带有特殊字符的URL,如'=‘。据我所知,如果您执行类似于$encrypted = $this->encrypt->encode($data->pid);的操作,它将返回一个在末尾带有双'=‘的字符串。
以下是关于CodeIgniter中的加密的说明。Encryption string on Codeigniter
https://stackoverflow.com/questions/28845718
复制相似问题