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

Redirect not working on my own server

Hi, I'm really confused with what could be the issue with this script. It all seems to work fine inside a Treehouse Workspace but will not redirect upon login on my server. (http://gateway.creativepixel.design)

On my server if credentials are correct it will reload the page, but if I then manually visit the /home.php page it will load, so the session has been created;.

Demo Credentials if Required;

Username: treehouse

Password: TeamTreeHouse

Here is a snapshot of my workspace. (https://w.trhou.se/3i39s6cobn)

Any help will be much appreciated

Thanks

1 Answer

I'm not sure what fixed the error. All I seemed to do was remove the code

    if ((isset($_SESSION['username']) != '')) 
    {
        header('Location: home.php');
    }

from index.php. I then saved it and pasted it back in.