亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當我嘗試更新我的一個用戶個人資料時,它會更新我的個人資料

當我嘗試更新我的一個用戶個人資料時,它會更新我的個人資料

PHP
一只名叫tom的貓 2022-07-16 11:16:22
這是我在用戶模型中的代碼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 進行更新


查看完整回答
反對 回復 2022-07-16
  • 1 回答
  • 0 關注
  • 108 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號