title: PHP page redirect after X seconds after echo output display
body: <p>My user registration PHP page for new user signup needs to show a confirmation message first, and then redirect to login page. For instance, after user successfully submits the registration form, I want to first show them a message that &quot;You have registered successfully, redirecting you to login page&quot;, then let this message remain displayed for 5 seconds, and then redirect to my site's login PHP page.</p>
  <p>I saw some existing SO questions like <a href="https://stackoverflow.com/questions/41511083/php-redirect-after-5-seconds">PHP redirect after 5 seconds</a> and <a href="https://stackoverflow.com/questions/6119451/page-redirect-after-certain-time-php/">Page redirect after certain time PHP</a>.</p>
  <p>However, the problem in the solutions offered by both of them is that they use the <code>header( &quot;refresh:5;url=newpage.php&quot; );</code> function which does NOT allow any message/output to be displayed BEFORE that header function call.</p>
  <p>Is there a way to achieve the display of message first, then wait for X seconds, and then finally redirect to login page?</p>