How to clear the form after sending? Or maybe I misunderstood?

I send the data through the form, and turn to a new page. If I update it, the form is sent again.

I usually applied

$hostname = Yii::$app->request->hostInfo; header("Location: ".$hostname."/basic/web/index.php?r=index/contact"); exit(); 

And everything works fine. But in this case, the redirect doesn't suit me, because I need to display the page.

 public function actionContact() { $model = new Contact(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { unset($_POST);//Этот варинат не помогает unset($_POST['Contact']);//Этот варинат не помогает unset($_POST['textarea']);//Этот варинат не помогает $model->textarea = null; //Этот варинат не помогает //--------------------------------- return $this->render('contact_yes'); //Мне нужна эта страница, потому ридеректить нельзя } else { return $this->render('contact', ['model' => $model]); } } 

If possible, mini-question 2, why is this happening?

  • Refreshing a page is sending a request similar to the previous one. Therefore, if you do not use a redirect, then your problem is not solved. All parameters (url, form data, etc.) are already stored in the browser history and will be used when the page is refreshed regardless of your desire. - Dmitriy Simushev
  • Start over with exploring php itself ... it's too early for you ... - Urmuz Tagizade
  • Tip: review the page rendering logic. Almost certainly you can give the same page on a GET request after the redirect. - Dmitriy Simushev
  • @Dmitriy Simushev Thank you for your reply. Already can not believe that this can not be wrestling. It became a shame. - gilo1212
  • @Urmuz Tagizade Thank you. So I study it for the entire time while I work on it. - gilo1212

0