duanfang5849 2015-10-14 20:06
浏览 267
已采纳

浏览器希望用户在第二页上按后退按钮时重新提交/刷新第一页

The 1st page is a search form that resubmits to itself and displays a list of homes. Then the user clicks on a home to display. When they are done looking at the home, they press the "back" button of the browser and then it is asking the user to refresh the page manually. I just want it to redisplay the last page as it was and not refresh it.

This is the way it used to work, but I cant figure out what caused it to start asking the user to refresh the page.

I'm not sure what code to show here. I'm using a Form with mostly PHP and very little JavaScript.

What could cause Page 1 to re-submit or refresh??

Update: I figured out that it has something to do with the PHP Session, however I dont know why its working correctly now:

This is the PHP code I had at the beginning of page:

`<?php  session_start();
$PrevNext = $_SESSION['PrevNextH'];
$queryH = $_SESSION['queryH'];
?>`

This is what I changed it to and it works fine now:

`       <?php   session_start();
        $PrevNext = $_SESSION['PrevNextH'];
        $queryH = $_SESSION['queryH'];
        ?>`

All I did was indent each line twice and the problem was solved. This does not make sense to me. Anyone know why this could happen?

  • 写回答

1条回答 默认 最新

  • doufang8282 2015-10-15 20:10
    关注

    Apparently there are a few quirky issues with PHP. The reason that this problem started was that I went into the page and cleaned up some of the code. I removed the indention's in front of my PHP code before the "DOCTYPE HTML" tag.

    Like:

    `<?php session_start();
    $PrevNext = $_SESSION['PrevNextH'];
    $queryH = $_SESSION['queryH'];
    ?>
    <!doctype html>`
    

    The fix was either put the indention's back in there or from what I found on a few other post here, the best solution is to put the "DOCTYPE HTML" tag before the PHP which worked also:

    `<!doctype html>
    <?php session_start();
    $PrevNext = $_SESSION['PrevNextH'];
    $queryH = $_SESSION['queryH'];
    ?>`
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示