It depends on your needs.
If you need to redirect the user after logging in, you should use the header redirection.
meta refresh is not recommended for the reasons mentioned above, but you can use meta refresh if necessary. for example, showing an ad on your site, and then after a certain number of seconds, you force the file to be downloaded or redirected to a new page.
here is a little script
Php
On the page
login.php displays the login form, after sending this page the data on the clearn_login_form.php page to clear the entries. clearn_login_form.php redirected to validate.php , and then validate.php redirected to admin_area/admin_main.php .
All this redirection is done to the backend, and the user will only see the login.php and admin_main.php , and if the user presses the return button in the browser, he will return to login.php
META
In meta-updates, the redirection is done on the browser / client side, which is a security risk because users will be able to see clear_login_form.php and validate.php in their URLs. also, if they hit buttom from admin_main.php , they will arrive at validate.php , from where they will again be redirected to admin_main.php
PHP is safe and fast and will hide some important file names from users where the meta is exposed, and users can perform CSRF or session attacks (if they find any holes)
Now you need to use the header on the first lines, this is a problem for you, to overcome this problem use the ob_start() function. but don't forget to put exit() right after each header command.
Note. The combination of ob_start and header() not good practice, and this confuses other programmers who work on your code. It is recommended that you use the header at the top of most locations or before any output is sent to the browser
function redirect($location) { header("location: $location"); exit(); }