How to do a redirect on the page ( to get rid of Re-submitting the form ) and print the error?

There is a registration form, after it failed to fill ( e.g. left blank, or the username has already been found ), after sending the page, when you try to update it POPs up a window of type "submit data".
How to make so that when you try to refresh the page, the window does not pop up and display the error.
Code:
class RegisterController extends AppController
{
 public function indexAction()
{
 if(isset($_POST['do_register'])) {
 $registerObj = new RegisterUser();
 $errors = $registerObj->checkUser($_POST, $_FILES);
 if(empty($errors)) {
 $registerObj->registerUser($_POST, $_FILES); // if no errors registered

 }else {
 $this->setData(compact("errors")); // if the error is - pass in, if you posivite header("Location: ... ") before or after this line, the error will not be displayed. 
}
}
}
}

How to solve this problem?
To get rid of the "Powercity resend form" and bring the error.
April 4th 20 at 13:03
2 answers
April 4th 20 at 13:05
Type in the address bar of your browser
site:qna.habr.com to do a redirect and display the error?
April 4th 20 at 13:07
How to solve this problem?


For a start unload back from the trolls and do a primary verification on the client side.
Recommended for reading:
https://developer.mozilla.org/ru/docs/HTML/HTML5/C...
Validation of form data

Find more questions by tags PHP