所以我的web应用程序上有一个帐户,当我试图更改密码时,它会将我重定向到错误页面,我不知道为什么。我想更改其中一个帐户的密码。
dc7f3da29862d3d5b3d3cd32356659ea7e85ed032b9c5144f5
密码是这样存储的(密码只有password
,所以我不介意这个在这里)
{
$result = $this->User->editUser($id,$username, $email, $name, $surname, $phone, $hash);
if ($result == true)
{
$this->set('has_message',true);
$this->set('css_name','success');
$this->set('errors',"<p>User successfully updated.</p>");
$profile = $this->User->getUserbyid($id);
$this->set('profile',$profile);
$this->User->closeConnection();
}
else
{
$this->User->closeConnection();
$this->set('has_message',true);
$this->set('css_name','error');
$this->set('errors',"<p>Something went wrong please try again.</p>");
}
}
这是编辑用户帐户的代码,我是PHP的新手,所以请告诉我是否还有你需要的代码。。。我一直在努力修复这个错误。。。。如果可能的话,我会在PHPMyAdmin中更改密码,因为我不介意用户不能更改他们的密码。
哈希方法:
$salt = $this->create_salt_password($username);
$hash = $salt . $password;
for ( $i = 0; $i < 100000; $i ++ )
{
$hash = hash('sha256', $hash);
}
$hash = $salt . $hash;
在config.php中,盐
define('AUTH_SALT','wcRwGxDzULe?s3J%R^W@9)r}xfXpESul5hC,z^ze.oz*1E|ys,Bk,:Q/z_I&M9..');
和
public function create_salt_password($username)
{
/** Creates a hash value for the password using
a prefixed random unique identifier value with a static characters and the username
*/
$salt = hash('sha256', uniqid(mt_rand(), true) .AUTH_SALT .strtolower($username));
return $salt;
}
登录脚本:
$salt = substr($results->password, 0, 64);
$password = $salt . $password;
for ( $i = 0; $i < 100000; $i ++ )
{
$password = hash('sha256', $password);
}
如果您想通过phpmyadmin
更改密码,请先找出使用哪种哈希方法将密码存储在数据库中(md5,sha1)。然后使用sha1-online.com等在线哈希工具生成密码,或者使用php脚本获取哈希后的密码并将其保存到数据库中。