I am withdrawing from the database a page name and putting into the this equal statement:
// Redirect if not there
if ($db_client === $session_client) {
require("custom.php");
} else {
require("general.php");
}
So here, $db_client is the client id stored for a custom page and $session_client being the id in the session. If it matches it should take the user to custom.php and if not it should take them to general.php
For some reason PHP shows me both pages. general.php on top and custom.php at the bottom of the general.php
I am using this on general page:
// If not page (path) is stored in db than show general
if (empty($pagename)) {
require_once("general.php");
} else {
require_once("$pagename");
}
Any way to fix this?
The problem can be in a different place than you think. Especially since we know that general.php could be included in several places.
So you need to get the actual order of includes to locate the problem.
Option A. Install xdebug module and you’ll be able to get the log of every call.
Option B is simpler. Write
echo 'including-', <N>;before every require operator.<N>is the number, unique for every usage. So you’ll be able to know which operator caused the unwanted include.BTW. Isn’t
require_once($pagename);better thanrequire_once("$pagename");?And ensure
$pagenamevariable is secured against the relative path attacks.