E
E
eldar_web2014-12-11 14:26:00
Yii
eldar_web, 2014-12-11 14:26:00

How to add a password to the database in Yii?

There is a form and we process this form in the controller:

public function actionCreate()
{
$model = new User;

if($_POST['user'])
$model->attributes = $_POST['user'];
$model->password = что тут делать ???
}

I want to add a hashed password to the DB.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
krypt3r, 2014-12-11
@krypt3r

Obviously, use the hash function, then call $model->save() if ActiveRecord. But why are you doing it in the controller? And don't do form validation?

V
Vit, 2014-12-11
@fornit1917

For these purposes, you should use the CPasswordHelper helper
www.yiiframework.com/doc/api/1.1/CPasswordHelper

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question