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