Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to make login page redirect to another page

i need help making a login page that redirects to another page on a site im working on

4 Answers

Matt Campbell
Matt Campbell
9,767 Points

You need to put

header('Location: http://www.example.com/');

at the end of the code that the form's action leads to. If that makes sense.

What this will do is, when the code for checking login credentials has run, if it's successful, it'll go to this page so put it in a conditional.

Matt Campbell
Matt Campbell
9,767 Points

Need a spot more detail. When do you want the redirect to happen? What's it redirecting to?

Is this when someone is logged out and they try to go to a page it redirects to the login page or it redirects back to the referrer page after successful log in?

i want the page to redirect to some kind of portal page after login and after it logs out id lik eit to return to home ..,.

Ok thanks for the help ...