本文介绍了cakephp密码验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var $ validate = array(
'password'=> array(
'passwordlength'=> array('rule'=> array 'between',8,50),'message'=>'Enter 8-50 chars'),
'passwordequal'=> array('checkpasswords','message'=& ')
)
);
function checkpasswords()
{
return strcmp($ this-> data ['Airline'] ['password'],$ this-> data ['Airline ']['确认密码']);
}
此代码不工作,并且总是给出错误消息,即使他们匹配。此外,当我做一个编辑,我得到followoing错误,因为没有密码字段。有任何修复
未定义的索引:password [APP / models / airline.php,第25行]
解决方案这里是错误
'passwordequal'=> array('checkpasswords','message'=>'Passwords不匹配')
到
'passwordequal'=> array('rule'=>'checkpasswords','message'=>'密码不匹配')
还有strcmp函数也有错误,因为它会在上面的代码中一直返回0(即False)
if (strcmp($ this-> data ['Airline'] ['password'],$ this-> data ['Airline'] ['confirm_password'])== 0)
{
return true;
}
return false;
var $validate = array(
'password' => array(
'passwordlength' => array('rule' => array('between', 8, 50),'message' => 'Enter 8-50 chars'),
'passwordequal' => array('checkpasswords','message' => 'Passwords dont match')
)
);
function checkpasswords()
{
return strcmp($this->data['Airline']['password'],$this->data['Airline']['confirm password']);
}
This code is not working and always gives the error message even if they match. Also when i do a edit i get the followoing error as there is no password field. is there any fix
Undefined index: password [APP/models/airline.php, line 25]
解决方案 here is the mistake
'passwordequal' => array('checkpasswords','message' => 'Passwords dont match')
I changed it to
'passwordequal' => array('rule' =>'checkpasswords','message' => 'Passwords dont match')
also strcmp function also had mistakes as it would return 0 (i.e False) all the time in the above code
if(strcmp($this->data['Airline']['password'],$this->data['Airline']['confirm_password']) ==0 )
{
return true;
}
return false;
这篇关于cakephp密码验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!