更新&显示会话中的数据

时间:2017-05-28 15:49:14

标签: php codeigniter session

我正在尝试从会话中执行更新配置文件。我很困惑,因为我可以打印用户名因为会话。但密码,全名和级别与数据库不匹配。

应该是 用户名:Ratih |全名:Ratih Cha |级别:销售

但结果 用户名:Ratih |全名:管理员|级别:管理员

这是我的控制器:

public function profile(){
        $uprofile = $this->salesModel->openProfile();
        $data = array(
                    "username" => $uprofile[0]['username'],
                    "fullname" => $uprofile[0]['fullname'],
                    "level" => $uprofile[0]['level'],
                    "pic" => $uprofile[0]['pic']
        );
        $this->load->view('v_navbar');
        $this->load->view('v_leftside');
        $this->load->view('v_profile', $data);
    }

模型

public function openProfile(){
        $username = $this->session->userdata('username');
        $data = $this->db->get('tuser');
        $this->db->where('username', $username);
        return $data->result_array();
    }

查看

<form role="form" action="<?php echo base_url()."index.php/SalesAdmin/update_profile/"?>" method="post">
  <div class="form-group">
    <label> Username : </label>
    <input type="text" class="form-control" id="datepick" name="fu_date" value="<?php echo $_SESSION['username']; ?>" readonly>
  </div>    

  <div class="form-group">
    <label> Full Name : </label>
    <input type="text" class="form-control" id="datepick" name="fu_date" value="<?php echo $fullname; ?>">
  </div>

  <div class="form-group">
    <label> Level : </label>
    <input type="text" class="form-control" id="datepick" name="fu_date" value="<?php echo $level; ?>" readonly>
  </div>

  <div class="form-group">
    <img data-name="<?php echo $_SESSION['username']; ?>" id="profile" class="img-circle" alt="Avatar" width="40px" height="32px"/><span></span></i>[enter image description here][1]
    <?php echo form_open_multipart('upload/do_upload');?>
    <?php echo form_upload('pic'); ?>
  </div>

  <div>
    <button type="submit" class="btn btn-default">Submit</button>
  </div>
</form>

0 个答案:

没有答案