所以我使用会话来保存用户名,然后检查它是否在那里。如果是,则使用它来更新与当前交易相关的信息。以下是我的代码:
public function update_edit()
{
/* echo " //// INSIDE UPDATE EDIT "; */
$this->form_validation->set_rules('fullname', 'الاسم الكامل', 'isset|required|min_length[6]|max_length[100]');
//echo 'Username: ';
//check that there are no form validation errors
if($this->form_validation->run() == FALSE)
{
echo " //// INSIDE FORM VALIDATION";
if(($this->session->userdata('username')!=""))
{
echo " //// INSIDE SESSION VALIDATION";
$data = array();
$session_user = $this->session->userdata('username');
if(isset($session_user) && $session_user != '' && $session_user != null)
{
$data = $this->profileModel->load_user_editable_data($session_user);
$this->load->view('layout/header');
$this->load->view('profile_edit', $data);
$this->load->view('layout/footer');
}else{
$this->error_page();
}
}else{
//$this->load->view('login');
$this->login();
}
}else{
echo "dasdaskhdkjashjdas";
$session_user = $this->session->userdata('username');
echo "Session User: " . $session_user;
if(isset($session_user) && $session_user != '' && $session_user != null)
{
echo "going to update;";
$complete = $this->profileModel->update_profile($session_user);
echo "<br>finished updating...";
if($complete == 1)
{
echo "Complete = " . $complete;
$this->load->view('layout/header');
$this->load->view('update_complete');
$this->load->view('layout/footer');
}elseif($complete == 2){
echo "Complete = " . $complete;
$this->error_page();
}
}
}
}
这里的问题是,在 echo dasdaskhdkjashjdas 之后,没有任何会话检查不起作用。我打印了这个值,它是空的。在函数运行良好并加载数据之前,这怎么可能?该功能应该检查加载的数据是否更改,然后提交新数据。
请帮忙 :)