这是我在用户模型中的代码
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的新手。亲切的问候,并感谢您提供的帮助。
在update_account
函数中,$this->session->id
在where子句中使用-这将始终是您的ID。
尝试将您要更改的用户的ID与其余数据一起发送,将其传递给update_account
函数,并使用正确的ID进行更新
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句