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'];
    ?>`
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。