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

PHP

Aamnah Akram
Aamnah Akram
17,549 Points

Redirect to a section of another page

I'm using the following code for redirecting to another page while passing a GET variable, and it works fine.

header("Location:index.php?status=thanks");

What i really want to do is redirect to a section of index.php, say #contact. I want it to show the contact form down below that was just submitted, not the content from the beginning. How do i do that?

I tried

header("Location:index.php#contact?status=thanks");

but it didn't work..

1 Answer

Aamnah Akram
Aamnah Akram
17,549 Points

Got it, i need to write it like this:

header("Location:index.php?status=thanks#contact");

the #contact part comes at the end.