簡體   English   中英

通過PHPmyadmin更改用戶密碼

[英]Changing the password of a user through PHPmyadmin

因此,我在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腳本獲取哈希密碼並將其保存到數據庫中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM