Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7820591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:21:17+00:00 2026-06-02T07:21:17+00:00

I has a action to change password. I dont understand why $error is null;

  • 0

I has a action to change password.
I dont understand why $error is null;

public function actionChangePassword() {
    $error;
    $player = $this->loadModel(Yii::app()->user->id);
    $oldpassword = '';
    $newpassword = '';
    $newpasswordrepeat = '';
    if (!isset($_REQUEST['oldpassword']) || !isset($_REQUEST['newpassword']) || !isset($_REQUEST['newpasswordrepeat'])) {
        $error = 'Vui long dien day du';
    }
    if (isset($_REQUEST['newpassword']) && isset($_REQUEST['newpasswordrepeat']) && isset($_REQUEST['oldpassword'])) {
        $oldpassword = $_REQUEST['newpassword'];
        $newpassword = $_REQUEST['newpassword'];
        $newpasswordrepeat = $_REQUEST['newpasswordrepeat'];
        if ($player->password != EncryptManager::encryptPassword($_REQUEST['oldpassword'])) {
            $error = 'Password cu khong dung';
            if ($newpasswordrepeat != $newpassword) {
                $error = 'Lap lai password khong dung';
            }
            if (count($newpassword))
                $error = 'Nhap password phai tren 6 ky tu';
            if (!isset($error)) {
                $player->password = EncryptManager::encryptPassword($_REQUEST['newpassword']);
                echo 'new password';
                if ($player->save()) {
                    $this->redirect(Yii::app()->baseUrl);
                }
            }
        }
    }  
    $this->render('//site/changepassword'
            , array('error' => $error)
    );
}

and my view changepassword

<div class="change-password-layout">
    <div class="change-password-content" >
        <?php echo CHtml::beginForm(); ?>
        <div class="change-password-detail-total">
            <div class="change-password-title"><p>Đổi mật khẩu</p></div>
            <div class="change-password-detail">

                <p>Mật khẩu cũ </p>
                <input type="password" name="oldpassword" value="">


            </div>
            <div class="change-password-detail">
                <p>Mật khẩu mới </p>
                <input type="password" name="newpassword" value="">

            </div>


            <div class="change-password-detail">
                <p>Xác nhận lại mật khẩu mới </p>
                <input type="password" name="newpasswordrepeat" value="">

            </div>

            <div class="submit-button">
                <input type="submit" name="" value="Xác nhận">
                <input type="button" name="" value="Hủy bỏ" />
                <div class="clearboth"></div>
            </div>
        </div>
        <?php echo $error; ?>
        <?php echo CHtml::endForm(); ?>
    </div>
    <div class="change-password-bg-total">
        <div class="change-password-bg"></div>
    </div> 



    <?php if ($error != '') { ?>
        <div class="msg-error">
            <div class="signup-line"></div>
            <div class="msg-item">
                <div class="msg-warning-icon"></div>
                <div class="msg-warning-label">
                    <?php echo $error; ?>
                </div>
                <div class="clearboth"></div>
            </div>
            <div style="height:5px"></div>
            <div class="signup-line"></div>
        </div>
    <?php } ?>

</div>


<script>
    $("#set-height").css('height',$(window).height());
</script>

When user don’t fill full of field we have error message if it success redirect to homepage.
Thank for advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:21:25+00:00Added an answer on June 2, 2026 at 7:21 am

    It’s initialized to null and, according to your code, will only be initialized to something if

    • None of the request parameters are initialized.
    • All request parameters are initialized and the user’s stored password is the same as the encrypted version of the old password. (There are some nested conditions that will set it under here.)

    So, if your user inputs the wrong ‘oldpassword’, then there’s no error.

    You want an else for this statement.

    if ($player->password != EncryptManager::encryptPassword($_REQUEST['oldpassword']))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSP which has jQuery and wanted to change the action message
I have a class that has an Action<string> called DisplayData ; In various points
I have two Perl files: action.pl and the other is test.pl action.pl has a
Given an app (your app) and a certain action it has, is it possible
DTF does not call the second action if the custom action assembly has more
I have an ASP.NET MVC 3 application which has a post action called Create
I'm creating a msi based installer (using InstallShield) that has a custom action to
I have a controller named Content, which has an Index action, which is associated
Specman has the apply() method to perform the same action on all elements of
Projects have many tasks and a task has a custom RESTful action called 'approve'.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.