douyicao2199 2013-06-13 14:38
浏览 18
已采纳

未设置$ _POST不起作用

Here is my code http://pastebin.com/DtK8MMtU when user pressing 'Next turn' button, $_POST["turnOver"] is getting set. Then script goes into this section

 if (isset($_POST["turnOver"])) {
                $_SESSION["state"] = 0;
                unset($_SESSION["rolls"] );
                unset($_SESSION["bet"]);
                unset($_SESSION["nextTurn"]);
                $_SESSION["turnNumber"]++;
                unset($_POST["turnOver"]);    
 }

By this row unset($_POST["turnOver"]); i want this block executes only once after user pressed 'Next turn' button, but this executed every time user refreshed page (i saw this by $_SESSION["turnNumber"] value, its increasing all the time i refresh page). Also, here is $_POST var_dump from xdebug:

array (size=1)
  'turnOver' => string ''... (length=9)

It means it is set?

  • 写回答

2条回答 默认 最新

  • dongyuqi3808 2013-06-13 14:41
    关注

    If the user is refreshing the page they will be sending the turnOver POST value each time. Unsetting post will only affect the rest of that page.

    Best thing to do is set a session value and set that the first time that turnOver is sent then check against that.

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

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM