T
T
Theory Theory2020-08-12 07:07:50
Yii
Theory Theory, 2020-08-12 07:07:50

Can't submit yii form?

<form action="/wow/index" method="post">
  <input type="text" name="name">
  <input type="text" name="email">
  <button type="submit" class="btn btn-primary">Отправить</button> 
</form>


class WowController extends Controller
{
  public function actionIndex() {
    echo 'Wow';
  }
}


Result:
Bad Request (#400)
Unable to verify your data submission.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-08-12
@Narbek

You need to insert the following code into the HTML form:

<input type="hidden" name="<?=Yii::$app->request->csrfParam; ?>" value="<?=Yii::$app->request->getCsrfToken(); ?>" />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question