Jump to content

Output text and then redirecting after a few seconds


siric

Recommended Posts

Hi,

 

I have been combing forums but cannot seem to get a answer that fits my problem.

 

I have a link that calls another page, writes to a table and redirects back to the first page.

 

I would like to output on the screen that the transaction has been completed, pause for a couple of seconds and then redirect to the first page.

 

I have used sleep() but all that does is to pause the calling of the second page and then call it and redirect immediately.

 

I have tried using flush before the sleep and before the echo but nothing works.

 

If I use

 

header("Refresh: 5; URL=firstpage.php");

 

all that does is to keep on calling the page repeatedly.

 

Any assistance would be appreciated.

 

Thanks

 

 

Just use a meta refresh ... pretty easy and works great!

 

<meta http-equiv="refresh" content="2;url=http://YOURPAGE.php">

 

Ahh, and the 2, just set that to the number of seconds you want to elapse before it changes the page to the page you set with YOURPAGE.php

ob_start();
echo "Your Message Here";
flush();
ob_end_flush();
sleep(3);
header("Location: Page.php");
exit;

 

 

HTH

Teamatomic

 

 

Just out of pure curiosity, and so I know myself, is there a reason it's better to do it this way rather than a meta refresh with url redirect?

ob_start();
echo "Your Message Here";
flush();
ob_end_flush();
sleep(3);
header("Location: Page.php");
exit;

 

 

HTH

Teamatomic

 

Nope that did not work.  Just brought a blank screen (or stayed on the one that was there before) for 3 seconds and then went to the called (2nd) page.

 

 

Ok, what I did was this

 

echo "<meta http-equiv='refresh' content='5; url=".$newpage." ' />\n";

 

as was suggested.

 

Because the redirect page has parameters that change,

 

could be

 

newpage.php?code=1234&poll=1 or newpage.php?code=32&poll=72 

etc

 

I built the variable before the meta tags (did not know that you could do this), and it works.

 

Thanks to all. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.