我做了一个是/否测验,游戏试图根据这些问题猜测你在想什么生物,只有 16 个可能的答案。
我想要做的是,如果用户在测验中途关闭网站,那么当他们返回测验时,他们会回答他们离开的同一个问题。以下是我到目前为止所做的,但它不能正常工作(请自己查看http://s504518.brunelweb.net/Creatures.php)您必须对第一个问题回答“是”,然后像我一样关闭浏览器到目前为止,仅针对该问题进行了一次会议。这是我到目前为止所做的一部分
//These are used for saving the session
$q2 = "<div class='questions'><p>{$questions[0][0]}</p></div>";
$q3 = "<div class='questions'><p>{$questions[0][1]}</p></div>";
$f2 = "<div class='questions'><form method ='GET' action='Creatures.php'>
<input type='submit' name='answer1' value='Yes' class='buttons' />
<input type='submit' name='answer1' value='No' class='buttons' />
</form></div>";
$f3 = "<div class='questions'><form method ='GET' action='Creatures.php'>
<input type='submit' name='answer2' value='Yes' class='buttons' />
<input type='submit' name='answer2' value='No' class='buttons' />
</form></div>";
//If start button has not been pressed, display nothing
if (!isset($_POST['start'])){
} //If start button has been pressed, display questions
else
{
//Display the first question
echo $firstquestion;
echo "<div class='questions'><form method ='GET' action='Creatures.php'>
<input type='submit' name='yes1' value='Yes' class='buttons' />
<input type='submit' name='no1' value='No' class='buttons' />
</form></div>";
}
//Question 2
if (isset($_SESSION['form']))
{
echo $_SESSION['question'];
echo $_SESSION['form'];
}
else{
if ($_GET['yes1']) //If answer to Q1 is yes then display this
{
echo "<div class='questions'><p>{$questions[0][0]}</p></div>";
showquestion(1);
$_SESSION['question'] = $q2;
$_SESSION['form'] = $f2;
}
}
我在这里想要实现的是,如果已经设置了会话,则显示该会话中的问题和表单,并且在他们单击开始按钮之前它没有显示任何内容。我不确定为什么它不能正常工作,任何帮助将不胜感激。