php 怎么移动表单位置,使用PHP会话记住用户在表单中的位置

我做了一个简短的测验,其中包含4个是/否的问题,我试图做的是如果用户关闭第二个问题时关闭网页,那么当他们重新打开页面时长达30天之后),他们将被带到他们留下的同一个问题。以下是我到目前为止的一些代码。

session_set_cookie_params(2592000); //Sets cookie to last for 30 days

session_start();

?>这是问题的代码

//Variables for functions

$number;

$creature2;

$creature3;

//Function for showing questions 2 to 7

function showquestion($number) {

echo "

}

//Function for showing questions 8 to 15

function showanswer($creature2,$creature3) {

echo "

Yes

No

";

}

//If start button has not been pressed, display nothing

if (!isset($_POST['start'])){

} //If start button has been pressed, display questions

else{

echo $firstquestion;

echo "

}

//Question 2

if ($_GET['yes1']) //If answer to Q1 is yes then display this

{

echo "

{$questions[0][0]}

";

showquestion(1);

}

//Question 3

if ($_GET['no1'])

{

echo "

{$questions[0][1]}

"; //If answer to Q1 is no then display this

showquestion(2);

}

//Questions 4 and 5

switch($_GET['answer1']) //If Question 2 is yes, do this

{

case 'Yes': echo "

{$questions[1][0]}

";

showquestion(3);

break;

case 'No': echo "

{$questions[1][1]}

";

showquestion(4);

}

//Questions 6 and 7

switch($_GET['answer2']) //If Question 3 is yes, do this

{

case 'Yes': echo "

{$questions[1][2]}

";

showquestion(5);

break;

case 'No': echo "

{$questions[1][3]}

";

showquestion(6);

}

//Questions 8 and 9

switch($_GET['answer3'])

{

case 'Yes': echo "

{$questions[2][0]}

";

showanswer('Eagle','Parrot');

break;

case 'No': echo "

{$questions[2][1]}

";

showanswer('Ostrich','Turkey_(bird)');

}

//Questions 10 and 11

switch($_GET['answer4'])

{

case 'Yes': echo "

{$questions[2][2]}

";

showanswer('Grasshopper','Ant');

break;

case 'No': echo "

{$questions[2][3]}

";

showanswer('Gorilla','Tiger');

}

//Questions 12 and 13

switch($_GET['answer5'])

{

case 'Yes': echo "

{$questions[3][0]}

";

showanswer('Penguin','Goose');

break;

case 'No': echo "

{$questions[3][1]}

";

showanswer('Frog','Salamander');

}

//Questions 14 and 15

switch($_GET['answer6'])

{

case 'Yes': echo "

{$questions[3][2]}

";

showanswer('Octopus','Jellyfish');

break;

case 'No': echo "

{$questions[3][3]}

";

showanswer('Goldfish','Eel');

}我知道这是可能的,因为我以前见过其他人这样做。测验在这里My Quiz

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值