0

This is a simple question which makes it painfully obvious that I need to take a php class...

I have as the first part of a an if / else statement that reads:

if (is_user_logged_in()){
//echo "user is signed in<P>";
header("Location: user-homepage.php");

so if the user is logged in and clicks a link that directs to /register.php, they should instead be redirected to the user-homepage.php.

What happens is they are directed instead directed to /register.php/user-homepage.php

My code is adding /user-homepage.php to the address instead of replacing /register.php with /user-homepage.php

What have I done wrong?

4 Answers 4

3

Use an absolute path rather than a relative one:

header("Location: /user-homepage.php");
Sign up to request clarification or add additional context in comments.

1 Comment

This is what I did in Wordpess and it fixed the issue. THANKS!
1

Try:

header("Location: http://your_domain.com/user-homepage.php");

The PHP manual says to use Absolute URLs.

Comments

1

You have used a relative file path. Try adding a forward slash to make it relative to the domain root.

header("Location: /user-homepage.php");

Comments

0

As given in section 14.30 of RFC 2616, "HTTP 1.1", use an absolute URL in the Location header.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.