How to make so that the header function was working in the middle of the script?

Met with the function header, namely the transition to another page. As I understand it only works if it is not "input" that is not what is displayed(text,numbers,whitespace, and so on.) and here I was wondering, say I have a script with a simple registration which is performed in reg.php and I want that after successful registration the user has moved to the main page.
1 way is understandable and you can simply write "You have successfully registered" and attach the link, but it's not.
header can not use as the script is still a form of registration.
June 27th 19 at 15:08
3 answers
June 27th 19 at 15:10
To help you)
But if briefly, then:
ob_start () first of all, just stop bringing in all of
header (......)
ob_flush() - in the end or when they want something to spit out
June 27th 19 at 15:12
So, why should it redirect using headers? There are crutches and simpler :) echo "<script>location.href='/done'</script>";
June 27th 19 at 15:14
header('Refresh: 0; URL=');

Find more questions by tags PHP