模型代码如下:
'/admin/login/captcha','message'=>'{attribute}'],
[['password','username'],'required'],
];
}
}控制器代码如下:
'yii\captcha\CaptchaAction',
'maxLength'=>4,
'minLength'=>3,
'width'=>10,
'height'=>10
];
}
public function actionIndex(){
$log = new LoginForm();
return $this->renderPartial("index",['model'=>$log]);
}
//授权规则
}视图代码如下:
beginPage()?>博客后台管理系统 =Html::cssFile('@web/css/bootstrap.min.css')?> =Html::cssFile('@web/css/style.css')?> =Html::jsFile("@web/js/jquery-1.11.3.min.js");?> =Html::jsFile("@web/js/bootstrap.min.js");?> beginBody()?>beginBody()?> endPage()?>博客后台管理系统
'post','action'=> \Yii::$app->urlManager->createUrl('/admin/login/index')])?>" title="点击刷新验证码" onClick="get_code(this);">
这里整个代码差不多了但是要设置一样更重要的 app/vendor/yiisoft/yii2/captcha/的文件下的CaptchaAction.php这文件中修改getVerifyCode($regenerate = false) 的方法$regenerate参数为true (getVerifyCode($regenerate = true))
下一篇:php如何实现分页查询