成功登录后,在codeigniter中编辑用户配置文件

时间:2015-10-26 10:04:14

标签: codeigniter

单击编辑配置文件按钮成功登录系统后,配置文件将更新,数据库也会更新,但更改不会反映在页面上。

public function editprofile()
        {
            $oActiveUser = $this->session->userdata ( 'member' );
            $iMemberId = $oActiveUser['member_id'];
            $aData['first_name'] = $this->input->post('fname');
            $aData['last_name']=$this->input->post('lname');
            $aData['email_id']=$this->input->post('emailid');
            $aData[ 'status'] = 'ACTIVE';
            $aWhere = array( 'member_id' => $iMemberId );
            $this->db_common->update( $this->sTable1 , $aData , $aWhere );
            $this->db_common->delete( $this->sTable3 , $aWhere );
            foreach($this->input->post('tech') as $technology) 
            {
                $data = array(
                    'member_id' => (int)$iMemberId,
                    'technology_id' => $technology
                 );
            $this->db_common->insert( $this->sTable3 , $data );
            $aResp = array( 'member_techno_id' => $this->db->insert_id());
            }
            redirect('front/Dashboard');

这是编辑个人资料的我的浏览页面: -

<form class="form-horizontal style-form" method="post" action="<?php echo base_url();?>front/Profile/editprofile" name="frmprofile" id="frmprofile">
                    <input type="hidden" class="form-control" name="id" id="id" value="<?php echo $oActiveUser['member_id'];?>">
                          <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label">First Name</label>
                              <div class="col-sm-10">
                                <input type="text" class="form-control required" name="fname" id="fname" value="<?php echo $oActiveUser['first_name'];?>">
                              </div>
                          </div>

                          <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label">Last Name</label>
                              <div class="col-sm-10">
                                  <input type="text" class="form-control required" name="lname" id="lname" value="<?php echo $oActiveUser['last_name'];?>">
                              </div>
                          </div>

                          <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label">Email Id</label>
                              <div class="col-sm-10">
                                  <input type="text" class="form-control required" name="emailid" id="emailid" value="<?php echo $oActiveUser['email_id'];?>">
                              </div>
                          </div>

                          <div class="form-group">
                              <label class="col-sm-2 col-sm-2 control-label">Technologies</label>
                              <div class="col-sm-10">
                                 <?php if(@$aTechCount>0){
                                    foreach( $aTechnology as $oType ){ ?>
                                      <li style="list-style-type:none;"><input type="checkbox" name="tech[]" value="<?php echo @$oType->technology_id; ?>" <?php if( in_array(@$oType->technology_id,$memTech)){ echo "checked";}?>> <?php echo strtoupper(@$oType->technology_name); } }?></li>
                              <span id="check_error" style="color:red;font-weight:bold;"></span>     
                              </div>
                          </div>

                          <center><input type="submit" class="btn btn-theme" name="upadate" id="update" value="Update" style="margin-bottom:5px;"><center>
                    </form> 

这是我的编辑个人资料代码,当我重定向到信息中心并再次点击编辑个人资料时,更新的数据不应该以表格形式显示。

这是我的编辑个人资料控制器加载视图

public function index()
    {
        $oActiveUser = $this->session->userdata ( 'member' );
        $id = $oActiveUser['member_id'];
        $sQuery = $this->db->query("SELECT technology_id FROM `member_technology` WHERE member_id = '$id'")->result();
        $tech_array = array();
        foreach($sQuery as $jQry){
            $tech_array [] = $jQry->technology_id;
        }
        $aData['memTech'] = $tech_array;
        $aWhere[ 'member_id' ] = $id;
        $aData[ 'aTechnology' ] = $this->db_common->get_data();
        $aData[ 'aTechCount' ] = count( $aData[ 'aTechnology' ] );
        $this->load->view('front/header');
        $this->load->view('front/editprofile',$aData);
        $this->load->view('front/footer');
    }

1 个答案:

答案 0 :(得分:0)

我认为由于这条线而发生了这个错误。

$this->load->view('front/header');
$this->load->view('front/editprofile',$aData);
$this->load->view('front/footer');

要避免这种情况,您可以删除以下行。

$this->load->view('front/header');
$this->load->view('front/footer');

中加载这些视图文件
$this->load->view('front/editprofile',$aData);

图。