时间:2021-07-01 10:21:17 帮助过:5人阅读
LoginController
load(Yii::$app->request->post())) {
print_r($model);
print_r(Yii::$app->request->post('userName'));
$info = new Userdb();
$info->userName = $model->username;
$info->password = $model->password;
$info->save();
return $this->render('showinfo', ['model' => $model]);
}else{
return $this->render('entry',['model' => $model]);
}
}
}
2.entry.php
'login-form',
'options' => ['class' => 'form-horizontal'],
'fieldConfig' => [
'template' => "{label}\n{input}\n{error}",
'labelOptions' => ['class' => 'col-lg-1 control-label'],
],
]); ?>
= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
= $form->field($model, 'password')->passwordInput() ?>
= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
先上代码 错误肯定就在这两个里边 但是不知道怎么解决 附网址:http://182.61.37.188/?r=login/entry
LoginController
load(Yii::$app->request->post())) {
print_r($model);
print_r(Yii::$app->request->post('userName'));
$info = new Userdb();
$info->userName = $model->username;
$info->password = $model->password;
$info->save();
return $this->render('showinfo', ['model' => $model]);
}else{
return $this->render('entry',['model' => $model]);
}
}
}
2.entry.php
'login-form',
'options' => ['class' => 'form-horizontal'],
'fieldConfig' => [
'template' => "{label}\n{input}\n{error}",
'labelOptions' => ['class' => 'col-lg-1 control-label'],
],
]); ?>
= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
= $form->field($model, 'password')->passwordInput() ?>
= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
做个调试看看,你先别用框架自带的Yii::$app->request->post()
获取,直接在控制器方法程序入口var_dump($_POST)
看看有没有值
通过$model->load(Yii::$app->request->post())就已经获取到了EntryForm的实例$model;打印$model->username试试
你可以尝试这种方法:
$model->load(Yii::$app->request->post(), '' );