小编Moh*_*han的帖子

Yii更改管理员密码

我创建了一个更改密码功能来更改管理员密码.我使用了这个 toutorial.
现在我在$ model-> validate()中遇到了问题.
谁能帮我??

调节器

    public function actionIndex()
    {
        $id = 1;
        $model = User::model()->findByAttributes(array('usertype' => $id));
        $model->setScenario('changePwd');

        if (isset($_POST['User'])) {
            $model->attributes = $_POST['User'];
            if ($model->validate()) {
                $model->password = md5($model->new_password);
                if ($model->save()) {
                    Yii::app()->user->setFlash('success', "Password Changed Successfully!");
                }

             } else {
                 Yii::app()->user->setFlash('error', "Change Password failed!");
             }
         }

      $this->render('index', array('model' => $model)); 
   }
Run Code Online (Sandbox Code Playgroud)

模型

    class User extends CActiveRecord
{
    public $old_password;
    public $new_password;
    public $repeat_password;
    /**
     * @return string the associated database table name
     */
    public …
Run Code Online (Sandbox Code Playgroud)

php passwords admin yii

6
推荐指数
1
解决办法
1662
查看次数

启用HTTPS后Laravel 5.7 @csrf无法正常工作

最初,我的laravel应用程序正在使用HTTP协议,然后将协议更改为HTTPS。
不幸的是现在我的应用程序登录现在无法正常工作。它向我显示419错误,对不起,您的会话已过期。我尝试了几种建议的解决方案。
https://laracasts.com/discuss/channels/laravel/post-request-in-laravel-57-error-419-sorry-your-session-has-expired

Laravel 419错误-VerifyCsrfToken问题

在Laravel 5.7中发布请求---错误-419对不起,您的会话已过期

但是这些都没有解决我的问题。

我正在使用CRUDBOOSTER插件来管理登录。

Routes.php。

/* ROUTER FOR WEB */
Route::group(['middleware' => ['web'], 'prefix' => config('crudbooster.ADMIN_PATH'), 'namespace' => $namespace], function () {

    Route::post('unlock-screen', ['uses' => 'AdminController@postUnlockScreen', 'as' => 'postUnlockScreen']);
    Route::get('lock-screen', ['uses' => 'AdminController@getLockscreen', 'as' => 'getLockScreen']);
    Route::post('forgot', ['uses' => 'AdminController@postForgot', 'as' => 'postForgot']);
    Route::get('forgot', ['uses' => 'AdminController@getForgot', 'as' => 'getForgot']);
    Route::post('register', ['uses' => 'AdminController@postRegister', 'as' => 'postRegister']);
    Route::get('register', ['uses' => 'AdminController@getRegister', 'as' => 'getRegister']);
    Route::get('logout', ['uses' => 'AdminController@getLogout', 'as' …
Run Code Online (Sandbox Code Playgroud)

php laravel

5
推荐指数
1
解决办法
231
查看次数

在 yii2 中调用非对象上的成员函数 saveAs()

我正在尝试在 Yii2 中运行一个应用程序,我尝试上传用户个人资料图片,它工作得很好,但当我尝试更新名称文件时,问题就开始了。它向我显示了类似的错误Call to a member function saveAs() on a non-object。我什至尝试在不进行任何更改的情况下进行更新..即使那时也向我显示相同的错误...但如果我更改图片,则会出现错误。这是我的控制器

public function actionUpdate($id)
{
    $model = $this->findModel($id);

    if ($model->load(Yii::$app->request->post()) && $model->save()) {

        // get the instance of uploaded file
        $imageName = $model->user_username;
        $model->file = UploadedFile::getInstance($model,'user_avatar');

        $model->file->saveAs( '/uploads/'.$imageName.'.'.$model->file->extension );

        //save the path in DB..
        $model->user_avatar = 'uploads/'.$imageName.'.'.$model->file->extension;
        $model->save();

        return $this->redirect(['view', 'id' => $model->user_id]);
    } else {
        return $this->render('update', [
            'model' => $model,
        ]);
    }
}
Run Code Online (Sandbox Code Playgroud)

模型规则

  public function rules()
            {
                return [

                [['user_email', 'user_password'], 'required'],
                    // [['user_password'], 'required'], …
Run Code Online (Sandbox Code Playgroud)

file-upload fatal-error yii2

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×2

admin ×1

fatal-error ×1

file-upload ×1

laravel ×1

passwords ×1

yii ×1

yii2 ×1