duanhe1903 2016-01-25 12:44
浏览 21
已采纳

<meta ... redirect ...里面的PHP标签[重复]

This question already has an answer here:

I have a question... I've developed a php safe login page, now when I run a check to redirect the user with "<?php header('location: home.php'); ?>" It doesn't work while on the actual domain for whatever reason.

However I thought of this code

<?php 
if (login_check($mysqli) == true) {
echo "<meta http-equiv='refresh' content='0;URL=home.php'>";
}
?>

Would that code be safe and functional? I am most concerned with the privacy one could exploit. It seems to work while I am on my local server, I have not uploaded it yet.

Is there another way that would be better than what I have currently?

</div>
  • 写回答

1条回答 默认 最新

  • duanmie9741 2016-01-25 13:10
    关注

    I would look into why header() isn't working on your remote server.

    The call is triggered within a condition block, maybe the condition is failing (login_check($mysqli) == true). Have you checked that?

    Another common cause for issues with header() is when the application outputs non-header data before calling header(). When you start to output data from a PHP script, PHP will automatically flush the headers. This means you cannot output any data before calling header(), as the header data will have already been flushed (so basically make sure you're not using echo, print, etc before your header() call.).

    See http://php.net/manual/en/function.header.php

    Also, I've noticed that you're not killing the script after printing the meta refresh. I would kill the script after printing the meta refresh code to prevent any other content being served to the user. So perhaps:

    if (login_check($mysqli) == true) {
      echo "<meta http-equiv='refresh' content='0;URL=home.php'>";
      die;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备