douzhen9428 2016-02-12 19:06
浏览 68
已采纳

如何仅在第一次重新加载页面

I need to reload or refresh the Page (index.php) at once on first time page loading. Because the google.com is giving the url to my page where there is no more data like index.php?id=10. So, I need to revert the url to index.php on first time only. I need solution in simple way. please any help?

  • 写回答

2条回答 默认 最新

  • douba9776 2016-02-12 19:15
    关注

    I'd recomend you use $_SESSION global array, for it allows you to pass information from one page to another (or the same one, like in this case) easily. Be sure you initialize sessions on each page you use it, though.

    The code should be something like this:

    session_start();    //Important! Without this, $_SESSION doesn't work
    
    //reload_index is a variable I'm using in the array, nothing restricted; you can use whichever name you like
    if (!isset($_SESSION['reload_index']) || ($_SESSION['reload_index'] == 'yes'))
    {
        $_SESSION['reload_index'] = 'no';
        header("Location: index.php");    //Or whatever page you want to go; you can add parameters as well, like index.php?id=10
    }
    
    //...Rest of the page
    

    I hope this helps you resolve your problem. Best regards.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?