Redirect Code

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
dajawu
Forum Commoner
Posts: 59
Joined: Fri May 23, 2008 10:16 am

Redirect Code

Post by dajawu »

I need a little help redirecting to another page after a script has already ran. I have a login page that holds the form and the PHP script to authenticate the user as well. After it all runs it displays a message saying you are logged on. How can I redirect the user to another page after all the form and script has already ran without getting an error?
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: Redirect Code

Post by Reviresco »

User header("Location: your_page.php") but you have to make sure it is before any output is sent by the page -- that includes line breaks and spaces. So whatever is you're checking or authenticating, check it first before the script does anything that might send output. Generally this means putting the authentication at the very top of the page.
Post Reply