首页 > 解决方案 > 无法在 codeigniter 中保留 post 变量

问题描述

如果用户单击提交按钮,我已经在 codeigniter 中创建了一个表单,他将被重定向到用户个人资料页面。但在我的情况下,用户被重定向到个人资料页面,但是当我重新加载个人资料页面时,我从以前的表单中发布的所有数据,即用户 ID 和名称都是空白的。

这是我的代码:

public function Profile() {
        $uId = decode($this->input->post('_id'));
        $name = decode($this->input->post('_name'));
        $this->data['ID'] = encode($uId);
        $this->data['contents'] = $this->load->view('web/profile', $this->data, true);
        $this->load->view('web/layout', $this->data);
    }

标签: phpcodeignitercodeigniter-3

解决方案


UserID将and存储name在会话变量中可以解决您的问题。加载后只需销毁使用的会话变量。


推荐阅读