Redirecting after printing text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Restrikted
Forum Newbie
Posts: 6
Joined: Sun Jun 01, 2008 10:37 pm

Redirecting after printing text

Post by Restrikted »

I've been searching for a while how to do this with no luck. What I want to do is after the person submits a form, the page tells them their submission was successful, and after about 3 seconds redirect them back to to the login page. Obviously I can't use header('Location: login.php'), since I've already output the form and confirmation onto the page. Is there any way to do redirect after printing text?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Redirecting after printing text

Post by onion2k »

You could use a meta refresh*. I'd just give the user a link to click on though in case they read slowly.

* http://en.wikipedia.org/wiki/Meta_refresh
Restrikted
Forum Newbie
Posts: 6
Joined: Sun Jun 01, 2008 10:37 pm

Re: Redirecting after printing text

Post by Restrikted »

That worked perfectly. Thanks.
LSJason
Forum Commoner
Posts: 45
Joined: Mon May 12, 2008 4:43 pm

Re: Redirecting after printing text

Post by LSJason »

Or, you can use a Javascript refresh:

Code: Select all

<script type="text/javascript">window.location="NEW URL";</script>
Post Reply