All says add these codes (header(..); exit();
)
We have: site.com/index.php?r=controller/index
, some form and fields with names "filters[...]
" We submited form and then after refreshing the page form is getting sent again.
added in index.php:
if ( isset($_POST['filters']) ) {
header("Location: site.com/index.php?r=controller/index");
exit;
}
added in controller:
unset($_POST);
What is going wrong?
You can use redirect() or refresh() function after save/validate data:
if($model->save()){
$this->redirect('site/login');
}else{
$this->render('index',[...]);
}
or
if($model->save()){
$this->refresh();
}else{
$this->render('index',[...]);
}