【发布时间】:2014-07-14 21:35:04
【问题描述】:
我使用 html 和 php 制作了一个问答游戏,网址为 "localhost/game/ques1.php","localhost/game/ques2.php"。
我在其中使用了会话,但用户可以通过将 URL 从 localhost/game/ques1.php 更改为 localhost/game/ques2.php 来回答下一个问题而无需回答问题 1。
如何阻止用户这样做??
【问题讨论】:
-
在
ques1.php中只需在会话中设置一个变量,如$_SESSION['lastQuestion']=1。然后在ques2.php中检查$_SESSION['lastQuestion'] == $currentQuestion - 1中的$currentQuestion是否与他们正在查看的页面相关。然后在加载ques2.php时,将lastQuestion设置为2,这样您就可以在3 上进行相同的测试,依此类推。 -
它工作了兄弟...非常感谢你的帮助
标签: php html session localhost