Jump to content

Page redirection, loading wrong page


imawake

Recommended Posts

Hi,

 

I have a file called content.php which contains the following code:

 

<?php 

// if it isn't a main section get the homepage
if ($subDir == null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/home/home.php');
}

// or if the url is a main section, get that main section
if ($subDir != null && $childDir == null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/' . $subDir . '/' . $subDir . '.php');
}

// If the url is a subpage of the main section get that content
if ($subDir != null && $childDir != null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/' . $subDir . '/' . $pageTitle . '.php');
}

?>

 

The problem I'm having is that I need my subpages to be displayed if I go to those subpages. At the moment, I'm seeing the homepage when I try to load a subpage like products.php. I'm new to php and if anyone can offer suggestions, I would greatly appreciate the help.

 

If you need more detail, please let me know.

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/91994-page-redirection-loading-wrong-page/
Share on other sites

Are they being passed in somewhere? $_GET variables?

 

// If the url is a subpage of the main section get that content
if ($subDir != null && $childDir != null) {
include ($_SERVER['DOCUMENT_ROOT'] . '/dev/includes/content_pages/' . $subDir . '/' . $pageTitle . '.php');
}

I think $childDir should be $pageTitle.

 

Looks like the variables aren't defined so it always defaults to the first option which is the home page. You could try to echo them and see if they are set or not or use isset on them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.