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.

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

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀