我正在尝试编写身份验证和登录脚本并且在那里很安静。我的数据库中保存了一个密码“密码”……它可以与密码“密码”一起使用,但不应该与“密码1!”一起使用 或前缀或后缀两个字符......它不应该接受它......但如果我输入不同的东西(不同的字符串,或更多的字符),它会给我一个正确的错误......
那是我的数据库表中唯一的行...没有重复的条目..
以下是代码
public function validate_login($valuethrown) {
$username = $valuethrown['username'];
$email = $valuethrown['email'];
$password = $valuethrown['password'];
echo "Values thrown to the model are : $username, $email, $password";
$authAdapter = $this->getAuthAdaptor();
$authAdapter->setIdentity($email)
->setCredential(md5($password));
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$data = $authAdapter->getResultRowObject(null,'password');
$auth->getStorage()->write($data);
$this->_redirect('home');
} else {
echo "</br>Wrong Password</br>";
}
//check login details
}
public function getAuthAdaptor() {
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$authAdapter->setTableName('users')
->setIdentityColumn('email')
->setCredentialColumn('password');
return $authAdapter;
}
帮助!!!!