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 7540989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:46:41+00:00 2026-05-30T07:46:41+00:00

I have this register system that doesn’t work. Can you please help me!! Also

  • 0

I have this register system that doesn’t work. Can you please help me!!

Also I must mention that I am using the Randomness extention .

the Yii error:

Property "Users.password2" is not defined.
/framework/db/ar/CActiveRecord.php(144)

SiteController.php

public function actionRegister()
        {
                $model = new Users;
                // collect user input data

                if(isset($_POST['ajax']) && $_POST['ajax']==='register-form')
                {
                        echo CActiveForm::validate($model);
                        Yii::app()->end();
                }


                if(isset($_POST['RegsiterForm']))
                {
                        $model->attributes=$_POST['RegsiterForm']; // set all attributes with post values

                        // NOTE Changes to any $model->value have to be performed BEFORE $model-validate() 
                        // or else it won't save to the database. 

                        // Check if question has a ? at the end

                        // validate user input and redirect to previous page if valid
                        if($model->validate())
                        {
                                // save user registration
                                $model->save();
                                $this->redirect($this->render('finished',array('model'=>$model))); // Yii::app()->user->returnUrl
                        }
                }
                // display the registration model
                $this->render('register',array('model'=>$model));
        }

Register.php (The view file, form was generated from Gii)

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'register-form',
        'enableAjaxValidation'=>true,
)); ?>

        <p class="note">Fields with <span class="required">*</span> are required.</p>

        <?php echo $form->errorSummary($model); ?>

        <div class="row">
                <?php echo $form->labelEx($model,'username'); ?>
                <?php echo $form->textField($model,'username'); ?>
                <?php echo $form->error($model,'username'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'password'); ?>
                <?php echo $form->textField($model,'password'); ?>
                <?php echo $form->error($model,'password'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'password2'); ?>
                <?php echo $form->textField($model,'password2'); ?>
                <?php echo $form->error($model,'password2'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'email'); ?>
                <?php echo $form->textField($model,'email'); ?>
                <?php echo $form->error($model,'email'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'fullname'); ?>
                <?php echo $form->textField($model,'fullname'); ?>
                <?php echo $form->error($model,'fullname'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'question'); ?>
                <?php echo $form->textField($model,'question'); ?>
                <?php echo $form->error($model,'question'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'answer'); ?>
                <?php echo $form->textField($model,'answer'); ?>
                <?php echo $form->error($model,'answer'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model,'verifyCode'); ?>
                <?php echo $form->textField($model,'verifyCode'); ?>
                <?php echo $form->error($model,'verifyCode'); ?>
        </div>

        <div class="row buttons">
                <?php echo CHtml::submitButton('Submit'); ?>
        </div>

<?php $this->endWidget(); ?>

</div><!-- form -->

user.php (the model)

public function rules()
        {
                // NOTE: you should only define rules for those attributes that
                // will receive user inputs.
                return array(
                        array('username','length','max'=>16),
                        // convert username to lower case
                        array('username', 'filter', 'filter'=>'strtolower'),
                        array('password','length','max'=>32, 'min'=>6),
                        array('password2','length','max'=>32, 'min'=>6),
                        // compare password to repeated password
                        array('password', 'compare', 'compareAttribute'=>'password2'), 
                        array('email, fullname', 'length', 'max'=>128),
                        // make sure email is a valid email
                        array('email','email'),
                        // make sure username and email are unique
                        array('username, email, password, salt', 'unique'), 
                        // convert question to lower case
                        array('question', 'filter', 'filter'=>'strtolower'),
                        array('answer','length','max'=>64),
                        // convert answer to lower case
                        array('answer', 'filter', 'filter'=>'strtolower'),
                        array('privilages, worns, status', 'numerical', 'integerOnly'=>true),
                        array('privilages','length','max'=>4, 'min'=>1),
                        array('worns','length','max'=>3, 'min'=>0),
                        array('status','length','max'=>2, 'min'=>0),
                        array('username, password, password2, salt, email, fullname, register_date, login_date, privilages, worns, status', 'required'),
                        // verifyCode needs to be entered correctly
                        array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd')),
                );
        }

 [..........]

        public function beforeSave()
        {
                while ($record2 === null){
                        $salt = Randomness::randomString(32);
                        $record2 = Users::model()->findByAttributes(array('salt'=>$salt));
                }
                $pass = hash('sha512', $this->password.$salt);
                $this->salt = $salt;
                $this->password = $pass;
                return true;
        }

and UserIdentity.php

<?php

/**
 * UserIdentity represents the data needed to identity a user.
 * It contains the authentication method that checks if the provided
 * data can identity the user.
 */
class UserIdentity extends CUserIdentity
{
        private $_id;

    public function authenticate()
    {
        $record=Users::model()->findByAttributes(array('username'=>$this->username));
        if($record===null)
            $this->errorCode=self::ERROR_USERNAME_INVALID;
        else if($record->password!==hash('sha512', $this->password.$record->salt))
            $this->errorCode=self::ERROR_PASSWORD_INVALID;
        else
        {
                        while ($record2 !== null){
                                $salt = Randomness::randomString(32);
                                $record2 = Users::model()->findByAttributes(array('salt'=>$salt));
                        }
                        $record->salt = $salt;
                        $record->password = hash('sha512', $this->password.$salt);
                        $record->save;
            $this->_id=$record->id;
            $this->setState('user_id', $record->id);
                        $this->setState('user_username', $record->username);
                        $this->setState('user_privilages', $record->privilages);
            $this->errorCode=self::ERROR_NONE;
        }
        return !$this->errorCode;
    }

    public function getId()
    {
        return $this->_id;
    }
}
  • 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-05-30T07:46:42+00:00Added an answer on May 30, 2026 at 7:46 am

    Your password2 doesn’t actually exist in the database table. I presume you’re using it simply for validation of the first password field, but by trying to create it from the model, you’re telling the model to look in the database for that field.

    You need to add it as a public property of your user model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Job Register Table and that table doesn't have any records. This
I have this weird problem.. I'm building an in-house app that should register all
Magento has this very nice MVC system where modules can register their 'frontname' and
I have this code to register dlls into my gac Assembly asm = Assembly.LoadFrom(argument);
I have this function: RegisterGlobalHotKey(Keys.F6, MOD_SHIFT | MOD_CONTROL); which call an API to register
I have this code in jQuery, that I want to reimplement with the prototype
I have this setup where in my development copy I can commit changes on
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I'm just starting to work on a logging library that everyone can use to

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.