這是我在用戶模型中的代碼public function update_account($first, $last, $email, $phone, $address, $company, $vat, $notes) { $this->db->query("UPDATE users SET name = ?, surname = ?, email = ?, phone = ?, address = ?, company = ?, vat = ?, notes = ? WHERE id = ?", array($first, $last, $email, $phone, $address, $company, $vat, $notes, $this->session->id));}這是我的用戶控制器中的代碼public function settings() { if ($this->user->is_logged()) { iF ($_POST) { $first_name = $this->input->post('ipt_first'); $last_name = $this->input->post('ipt_last'); $email = $this->input->post('ipt_email'); $phone = $this->input->post('ipt_phone'); $address = $this->input->post('ipt_address'); $company = $this->input->post('ipt_company'); $vat = $this->input->post('ipt_vat'); $notes = $this->input->post('ipt_notes'); $this->user->update_account($first_name, $last_name, $email, $phone, $address, $company, $vat, $notes); } if ($this->uri->segment(3)) { if ($this->user->is_admin($this->session->email)) { $udata['uinfo'] = $this->user->details($this->uri->segment(3)); load_content('user/settings', $udata); } } else { $udata['uinfo'] = $this->user->details($this->session->id); load_content('user/settings', $udata); } } else { redirect(); }}基本上我需要它來更新他們的信息,如果它是客戶并且如果您是管理員(mysql 0 中的 perm 級別 1 默認為客戶)設置我自己的設置或其他人,如果我正在查看他們的設置頁面。我的 HTML 表單可以正常工作,因為我可以使用上面的代碼更新我自己的詳細信息,但是在查看客戶設置時,我無法覆蓋它們,因為它會更改我自己的設置。我希望我已經添加了足夠的細節,如果沒有請公平,因為我對編程和 stackoverflow 相對較新。親切的問候,并感謝您提供的幫助。
1 回答

偶然的你
TA貢獻1841條經驗 獲得超3個贊
在update_account
函數中,您$this->session->id
在 where 子句中使用 - 這將始終是您的 id。
嘗試將要更改的用戶的 ID 與其余數據一起發送,將其傳遞給update_account
函數并使用正確的 ID 進行更新
- 1 回答
- 0 關注
- 108 瀏覽
添加回答
舉報
0/150
提交
取消