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

未设置$ _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 06: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部