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 "You have registered successfully, redirecting you to login page", then let this message remain displayed for 5 seconds, and then redirect to my site's login PHP page.
I saw some existing SO questions like PHP redirect after 5 seconds and Page redirect after certain time PHP.
However, the problem in the solutions offered by both of them is that they use the header( "refresh:5;url=newpage.php" );
function which does NOT allow any message/output to be displayed BEFORE that header function call.
Is there a way to achieve the display of message first, then wait for X seconds, and then finally redirect to login page?