简体   繁体   English

通过PHPmyadmin更改用户密码

[英]Changing the password of a user through PHPmyadmin

So I have an account on my web application, when I try to change the password it redirects me to the error page and I can't figure out why. 因此,我在Web应用程序上拥有一个帐户,当我尝试更改密码时,它会将我重定向到错误页面,但我不知道为什么。 I want to change the password to one of the accounts. 我想将密码更改为其中一个帐户。

dc7f3da29862d3d5b3d3cd32356659ea7e85ed032b9c5144f5

The password is stored as this (the password is only password so I don't mind this being here) 密码以此存储(密码仅是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>");
                            }
                        }

This is the code for editing a user account, I am new to PHP so please tell me if there is any more code you need...I am stuck trying to fix this error....and if possible I would just change the password in PHPMyAdmin instead as I don't mind if users cannot change their password. 这是用于编辑用户帐户的代码,我是PHP的新手,所以请告诉我是否需要更多代码...我一直在尝试解决此错误。...如果可能的话,我将更改而是使用PHPMyAdmin中的密码,因为我不介意用户是否无法更改密码。

Hash methods: 哈希方法:

$salt = $this->create_salt_password($username);
                $hash = $salt . $password;
                for ( $i = 0; $i < 100000; $i ++ ) 
                {
                    $hash = hash('sha256', $hash);
                }
                $hash = $salt . $hash;

And in config.php the salt 并在config.php中添加盐

define('AUTH_SALT','wcRwGxDzULe?s3J%R^W@9)r}xfXpESul5hC,z^ze.oz*1E|ys,Bk,:Q/z_I&M9..');

and

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;
        }

Login script: 登录脚本:

$salt = substr($results->password, 0, 64);
                $password = $salt . $password;
                for ( $i = 0; $i < 100000; $i ++ ) 
                {
                    $password = hash('sha256', $password);
                }

If you want to change your password through phpmyadmin , first find out which hashing method is used to store the password in the database (md5, sha1). 如果要通过phpmyadmin更改密码,请首先找出使用哪种哈希方法将密码存储在数据库中(md5,sha1)。 Then generate the password using online hash tools like sha1-online.com or just get the hashed password using php script and save it to your database. 然后使用sha1-online.com等在线哈希工具生成密码,或者仅使用php脚本获取哈希密码并将其保存到数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM