使用会话的 php 多步骤表单的问题
我对 php 多步骤表单有疑问。 我只需要在一个页面中执行不同表单之间的切换。 在此页面中,我切换以下情况:
$_SESSION["profilo"]= $_POST["profilo"];
$_SESSION["periodic"]=$_POST["periodic"];
$_SESSION["from"]=$_POST["from"];
$_SESSION["to"]=$_POST["to"];
$_SESSION["weekdays"]=$_POST["weekdays"];
$_SESSION["start"]=$_POST["start"];
$_SESSION["expire"]=$_POST["expire"];
$step = 1;
if(!isset($_SESSION["profilo"]))
{
$step = 1;
}
elseif(isset($_SESSION["profilo"]) && !isset($_SESSION["periodic"]))
{
$step = 2;
}
elseif(isset($_SESSION["periodic"]) && !isset($_SESSION["start"]))
{
$step = 3;
}
else
{
$step = 4;
}
然后执行指令
WriteForm($step);
,该指令是一个根据 $step 的值切换不同形式的函数。 问题是,在第二步之后,它会将我踢回第一个表单,而不是执行第 3 步。我认为问题是,第二次我点击“提交”时,在我的第二个表单中,我没有“个人资料” " 字段:我的页面的以下执行会使用 NULL 值覆盖 $_SESSION["profilo"],从而返回到 if 循环的步骤 1。 我该如何解决这个问题?
编辑: 为了提供信息:form1只有“个人资料”字段,form2有“定期”,“从”,“到”,“工作日”,form3有“开始”,“过期”。
I have a problem with a php multistep form.
I need to perform the switching between the different forms only in one page.
In this page I switch the following cases:
$_SESSION["profilo"]= $_POST["profilo"];
$_SESSION["periodic"]=$_POST["periodic"];
$_SESSION["from"]=$_POST["from"];
$_SESSION["to"]=$_POST["to"];
$_SESSION["weekdays"]=$_POST["weekdays"];
$_SESSION["start"]=$_POST["start"];
$_SESSION["expire"]=$_POST["expire"];
$step = 1;
if(!isset($_SESSION["profilo"]))
{
$step = 1;
}
elseif(isset($_SESSION["profilo"]) && !isset($_SESSION["periodic"]))
{
$step = 2;
}
elseif(isset($_SESSION["periodic"]) && !isset($_SESSION["start"]))
{
$step = 3;
}
else
{
$step = 4;
}
then I execute the instruction
WriteForm($step);
which is a function that switches the different forms depending on the value of $step.
The problem is that after the second step, it kicks me back to the first form insted of going step 3. I think the problem is that the second time I hit "Submit", in my second form i don't have a "profilo" field: the following execution of my page overwrite $_SESSION["profilo"] with a NULL value going back to step 1 cause of the if cycle.
How can I solve this problem?
EDIT:
for sake of information: form1 have just "profile" field, form2 have "periodic", "from", "to", "weekdays", form3 have "start", "expire".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)