#表名是用戶#需要更新用戶表密碼字段上笨
##型號名稱是user_model ##
###控制器的名字是get_password ###
問題 - 對密碼沒有改變,仍然爲老
> model(user_model)
public function updatePassword($email,$data)
{
$data1=array('password'=>$data);
$this->db->where('email','$email');
$this->db->update('users','password');
$success = $this->db->affected_rows();
if(!$success){
error_log('Unable to updatePassword');
return false;
}
return true;
}
> controller(get_password)
public function index($rs=FALSE)
{
$this->load->database();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->model('user_model');
$this->load->library('session');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('password', 'password', 'required');
$this->form_validation->set_rules('passconf', 'password Confirmation', 'required|matches[password]');
if ($this->form_validation->run() == FALSE)
{
echo form_open();
$this->load->view('users/fpre');
}
else
{
$data = array(
'password' => md5($this->input->post('password')),
);
$email =array(
'email' =>$this->input->post('email')
);
$this->user_model->updatePassword($data,$email);
echo "Congratulations!";
}
}
,也沒有任何錯誤,但密碼未更新,在用戶保持相同table..i找不到問題,請幫我找我t出..
不要使用MD5口令可以得到砍死你應該使用PHP的密碼哈希http://php.net/manual/en/function.password-hash.php密碼列在數據庫varchar 255和驗證http://php.net/manual/en/function.password-verify.php – user4419336