0

Hej guys,

I want to be able to refresh a page when a button is clicked and then show a message. Either way I do this ;

        echo "<br><h4>Test Words</h4><br>";
        header("Location: testpage.php");

or

        header("Location: testpage.php");
        echo "<br><h4>Test Words</h4><br>";

It refreshes and does not show me the words. Is this possible to do? The reason I have done this is I want to be able to do all my PHP / everything, refresh the page, so it has up to date details. Then show me a message?

Zoltan
  • 93
  • 7
  • Look for "flash messages". Usually you do the redirect, then let the redirect target page display the message. Mashing output with a redirect instruction doesn't work. (Short of a HTTP `Refresh:` header of course.) – mario Aug 23 '15 at 21:03
  • As soon as you do a header()-call, no text will be output and the header will be sent which in this case leads to immediate redirect. You'll need to send a HTML-Button to the client implementing that functionality in HTML or JS. – PhilMasteG Aug 23 '15 at 21:03
  • And the more common approach: [displaying a message after redirecting the user to another web page](http://stackoverflow.com/q/12249906) – mario Aug 23 '15 at 21:04
  • header("Refresh:1"); seems to be my best option. Reading links, it is alot more complex than it really needs to be, just to display a message. Thanks. – Zoltan Aug 23 '15 at 21:26

0 Answers0