如何使用相同的列名(電子郵件,密碼)在兩個不同的表如何使用兩個不同的表
型號代碼重置口令重置密碼如下所示
public function resetpassword($user) {
$data = array(
'password' => ($this->input->post('newpassword'))
);
//$where = "id=5";
$where = "id=$user";
$this->db->where($where);
$this->db->update('supplier_registration', $data);
}
控制器代碼作爲如下圖所示
public function ResetPassword() {
$emaill = $this->input->post('emaill');
$otp = $this->input->post('otp');
//$this->form_validation->set_rules('emaill', 'emaill', 'required|min_length[10]|max_length[30]|matches[otp]');
$this->form_validation->set_rules('otp', 'otp', 'required|min_length[6]|max_length[6]');
$this->form_validation->set_rules('newpassword', 'newpassword', 'trim|required|max_length[15]|min_length[8]|alpha_numeric|matches[confirmpassword]');
$this->form_validation->set_rules('confirmpassword', 'Confirm password', 'trim|required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('login');
} else {
if($this->session->userdata('otp') == "$otp" && $this->session->userdata('findemaill') == "$emaill") {
$user = $this->session->userdata['idd'];
$this->load->model('Login_model');
$result['data'] = $this->Login_model->resetpassword($user,$emaill);
$this->session->set_flashdata('success_msg', 'successfull reset the password');
$this->load->view('login');
}
}
}
內不同型號的2種方法你一樣想要使用單個函數重置具有相同列名的兩個表中的密碼? –
是的,我想重置密碼,使用兩個不同的表列名稱是相同的 –
如果這些表是1to1相關的,就像每個行具有相同的ID值,您可以設置更新表後的觸發器。 – Tpojka