Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP重定向问题_Php - Fatal编程技术网

PHP重定向问题

PHP重定向问题,php,Php,我有一个程序,可以打印用户id列表的报告。该程序应该为上传列表上的用户逐个打印报告。问题是,当我运行打印过程并打印indexInList=30的报告时,出现错误: 此网页有一个重定向循环 位于的网页导致重定向过多。清除此站点的Cookie或允许使用第三方Cookie可能会解决此问题。如果不是,则可能是服务器配置问题,而不是计算机问题 我试图清理cookie,但仍然得到相同的错误 我在这里附上了一些代码,希望任何人都能帮助我: $sessionData['first_name'] = $fou

我有一个程序,可以打印用户id列表的报告。该程序应该为上传列表上的用户逐个打印报告。问题是,当我运行打印过程并打印indexInList=30的报告时,出现错误:

此网页有一个重定向循环
位于的网页导致重定向过多。清除此站点的Cookie或允许使用第三方Cookie可能会解决此问题。如果不是,则可能是服务器配置问题,而不是计算机问题

我试图清理cookie,但仍然得到相同的错误

我在这里附上了一些代码,希望任何人都能帮助我:

  $sessionData['first_name'] = $foundUser->first_name;
  $sessionData['last_name']  = $foundUser->last_name;

  // Overwrite $_REQUEST variable with parameters before including
  // the hpa report
  $_REQUEST = array(
    'user_id'      => $foundUser->id,
    'bulkprinting' => true
  );
  if($nopeergroup) { $_REQUEST['nopeergroup'] = $nopeergroup; }
  if($nolabpage) { $_REQUEST['nolabpage'] = $nolabpage; }
  if($hideScreeningOnly) { $_REQUEST['hideScreeningOnly'] = $hideScreeningOnly; }
  if($showOnlyScreening) { $_REQUEST['showOnlyScreening'] = $showOnlyScreening; }
  if($hideHoldMailing) { $_REQUEST['hideHoldMailing'] = $hideHoldMailing; }

  $includeValue = include __DIR__.'/../hpa/hpa.php';

  $url = sprintf(
    "/content/8520?print=1&bulkprinting=1&filename=%s&indexInList=%s" .
    "&nopeergroup=%s&nolabpage=%s&hideScreeningOnly=%s" .
    "&showOnlyScreening=%s&hideHoldMailing=%s",
    $filename, $indexInList, (int)$nopeergroup, (int)$nolabpage,
    (int)$hideScreeningOnly, (int)$showOnlyScreening, (int)$hideHoldMailing);

  if($hradata[0] !== false) {
    $sessionData['hra_id'] = $hradata[0]['id'];
  }
  if($screeningdata[0] !== false) {
    $sessionData['screening_id'] = $screeningdata[0]['id'];
  }

  if($includeValue !== 1) {
    // Redirect to URL
    $sessionData['message']     = $messages_set[$includeValue];
    $_SESSION['printing_set'][] = $sessionData;

    redirect($url);
  }

  $sessionData['markAsMailed'] = true;
  $_SESSION['printing_set'][]  = $sessionData;
?>
<script type="text/javascript">
  function waitPrint() {
    window.print();
    var t = setTimeout("timed()", 1000);
  }
  function timed() {
    window.location.replace("<?php echo $url ?>");
  }

  if(window.attachEvent) {
    window.attachEvent("onload", waitPrint);
  } else if(window.addEventListener) {
    window.addEventListener("load", waitPrint, false);
  }
</script>
$sessionData['first\u name]=$foundUser->first\u name;
$sessionData['last_name']=$foundUser->last_name;
//在包含之前使用参数覆盖$\请求变量
//hpa报告
$\u请求=数组(
'user_id'=>$foundUser->id,
“批量打印”=>true
);
如果($nopeergroup){$\u请求['nopeergroup']=$nopeergroup;}
如果($nolabpage){$\u请求['nolabpage']=$nolabpage;}
if($hideScreeningOnly){$\u请求['hideScreeningOnly']=$hideScreeningOnly;}
如果($showOnlyScreening){$\u请求['showOnlyScreening']=$showOnlyScreening;}
如果($hideHoldMailing){$\u请求['hideHoldMailing']=$hideHoldMailing;}
$includeValue=include/hpa/hpa.php';
$url=sprintf(
“/content/8520?print=1&bulkprinting=1&filename=%s&indexInList=%s”。
“&nopeergroup=%s&nolabpage=%s&hideScreeningOnly=%s”。
“&showOnlyScreening=%s&HideHoldMail=%s”,
$filename,$indexInList,(int)$nopeergroup,(int)$nolabpage,
(int)$仅隐藏筛选,(int)$仅显示筛选,(int)$隐藏邮寄);
如果($hradata[0]!==false){
$sessionData['hra_id']=$hradata[0]['id'];
}
如果($screeningdata[0]!==false){
$sessionData['screening_id']=$screeningdata[0]['id'];
}
如果($includeValue!==1){
//重定向到URL
$sessionData['message']=$messages\u set[$includeValue];
$\u SESSION['printing\u set'][]=$sessionData;
重定向($url);
}
$sessionData['markAsMailed']=true;
$\u SESSION['printing\u set'][]=$sessionData;
?>
函数waitPrint(){
window.print();
var t=setTimeout(“timed()”,1000);
}
函数计时(){
窗口。位置。替换(“”);
}
如果(窗口附件){
window.attachEvent(“onload”,waitPrint);
}else if(window.addEventListener){
window.addEventListener(“加载”,waitPrint,false);
}

听起来你有很多文件需要打印

您可以更改浏览器设置(我似乎记得您可以在Firefox中更改),以允许超过30个循环

或者,您可以始终将代码限制为30个循环,然后等待进一步的用户交互继续到下一个30个循环


第三种选择是创建一个Word文档或PDF,每页上都有一份报告,然后保存文件并打印出来——这会有点麻烦(某种程度上),但至少你可以一次打印所有内容。

为了将
$includeValue
设置为任何内容,文件
\uuuu DIR\uuuu.'/../hpa/hpa.php'
必须包含一个return语句,如for
include
示例5所示<如果包含的文件返回值,则代码>包含仅在调用时返回值

如果脚本仍然生成无限循环,则包含文件中的逻辑不正确,并且始终生成的值不是
1

基本上,您的问题归结为以下代码:

$includeValue = include __DIR__.'/../hpa/hpa.php';
if($includeValue !== 1) {
    // Redirect
}

当站点被错误配置为重定向循环时,浏览器有内置的检查来帮助您,并且您使用的浏览器的限制必须为30。您故意构建了一个重定向循环,但浏览器不知道这一点。与其使用
window.location.replace()
方法,不如使用自动提交的表单?这对于浏览器来说应该是不同的,并且允许循环按设计进行

<script type="text/javascript">
  function waitPrint() {
    window.print();
    var t = setTimeout("timed()", 1000);
  }
  function timed() {
    window.reloadForm.submit();
  }
  if(window.attachEvent) {
    window.attachEvent("onload", waitPrint);
  } else if(window.addEventListener) {
    window.addEventListener("load", waitPrint, false);
  }
</script>

<form name="reloadForm" action="<?php echo $url ?>">
</form>

函数waitPrint(){
window.print();
var t=setTimeout(“timed()”,1000);
}
函数计时(){
window.reloadForm.submit();
}
如果(窗口附件){
window.attachEvent(“onload”,waitPrint);
}else if(window.addEventListener){
window.addEventListener(“加载”,waitPrint,false);
}

谢谢你的回复。你知道如何解决这个问题吗?