php数据出错怎么验证,php – Yii2 – 错误请求(#400)无法验证您的数据提交

我的yii2应用程序工作正常,直到昨天,但今天提交表单显示错误. “错误请求(#400)无法验证您的数据提交.”

我在stackoverflow上发现了很多这样的问题,人们建议禁用csrf验证我也尝试禁用csrf验证.我甚至更新了我的作曲家仍然无法正常工作.

请提出任何其他可能的解决方案

这是我的表格代码: –

Open an Account

$form = ActiveForm::begin([

'id' => 'live-account-form',

'enableClientValidation' => true,

'fieldConfig' => [

'template' => '{input}{error}',

'options' => [

'tag' => false,

]

],

'options' => [

'class' => 'form-horizontal'

]

]);

?>

First Name*

= $form->field($model, 'first_name')->textInput(['placeholder' => "Enter First Name"]) ?>

Last Name*

= $form->field($model, 'last_name')->textInput(['placeholder' => 'Enter Last Name']) ?>

Email*

Country*

= $form->field($model, 'country')->dropDownList(

ArrayHelper::map(PhCountry::find()->all(), 'intid', 'country_name'),

[

'prompt' => 'Select Country',

'onchange' => '$( "select#signupform-country_code" ).html("showLoading");

$.get( "index.php/site/fetch-country-code?id='.'"+$(this).val(),

function(data) {

$( "#signupform-country_code" ).val(data);

});'

]

) ?>

Phone Number*

= $form->field($model, 'country_code')->textInput(['placeholder' => 'Code', 'class' => 'country-code form-control']) ?>

= $form->field($model, 'phone')->textInput(['placeholder' => 'Enter Phone Number', 'class' => 'enter-phone-number form-control']) ?>

Create Account

ActiveForm::end();

?>

这是我在控制器内的动作代码: –

public function actionIndex()

{

Yii::$app->controller->enableCsrfValidation = false;

$model = new SignupForm();

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

//print_r($model);

if ($user = $model->signup()) {

if($model->sendRegistrationEmail($user)) {

Yii::$app->session->setFlash('emailSent', 'An email containing confirmation link is sent to your email Address.');

if (Yii::$app->getUser()->login($user)) {

return $this->goHome();

}

}

}

//exit;

}

return $this->render('index', [

'model' => $model,

]);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值