問題は、保存ボタンをクリックすると、データがデータベースにリストされていることです。この場合、ユーザーの名前は頭の中で同じままです。私がlogged_inを実行した場合にのみ、ユーザーの名前は変更されます。ダッシュボードから外出することなく、セッションの助けを借りて名前を変更するにはどうすればいいですか?データ更新Codeigniter with session
モデル:
function get_user_by_id($id){
$user = $this->ci->db
->where($this->identifier_field, $id)
->get($this->user_table);
$user_details = $user->row();
return $user_details;
}
function get_user($data)
{
$this->ci->db->select('*');
$this->ci->db->from('users');
$this->ci->db->where('id', $data);
$query = $this->ci->db->get();
$result = $query->result();
return $result;
}
// Update Query For Selected Student
function update_user($id, $data)
{
$this->ci->db->where('id', $id);
$this->ci->db->update('users', $data);
}
コントローラー:
この質問の私の理解から、function show_user()
{
$data = array(
'lang' => $lang,
'test_condition' => false,
'reg_condition' => false,
'current_page' => '',
'head_title' => $lang['profile']
);
$id = $this->session->userdata('identifier');
$data['user'] = $this->authentication->get_user_by_id($id);
/*$data['single_user'] = $this->authentication->get_user($id);*/
$this->load->view('profile', $data);
}
function profile()
{
$id = $this->input->post('id');
if (isset ($id)) {
$data = array(
'email' => $this->input->post('email'),
'birthday' => $this->input->post('birthday'),
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'language_id' => $this->input->post('language'),
);
$this->authentication->update_user($id, $data);
}
$this->show_user();
}
名前を印刷するために使用した変数を投稿するか、名前を印刷するヘッドビューブロックを投稿してください。 –