douge7771 2011-04-22 21:26
浏览 33
已采纳

重定向的平等声明

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?

  • 写回答

1条回答 默认 最新

  • duanlao1552 2011-04-28 16:56
    关注

    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 than require_once("$pagename");? And ensure $pagename variable is secured against the relative path attacks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch