2012-08-07 44 views
0

我有一个这样的形式:链接不保存

<form id="candida-form" action="index.php?gender=<? echo $sex; ?>?step=<? echo $step; ?>" method="get"> 
    <? if ($step == -1): ?> 

    <div style="padding-left: 95px;padding-top: 40px;"> 
          <div class="radio-option"><input type="radio" id="male" name="form_sex" value="0" checked /> <label for="male" style="cursor:pointer;"><img src="images/icon_man.png" /> Male</label></div> 
          <div class="radio-option"><input type="radio" id="female" name="form_sex" value="1" /> <label for="female" style="cursor:pointer;"><img src="images/icon_woman.png" /> Female</label></div> 
          <div class="radio-option" style="padding-top:9px;"><input type="radio" id="child" name="form_sex" value="2" /> <label for="child" style="cursor:pointer;"><img src="images/icon_child.png" /> Child</label></div></div> 
          <div class="clear"></div> 

<div class="submit-wrapper"><input type="submit" id="nextstep" value="Next Step" /></div> 

<? elseif ($step == 0): ?> 
        <div class="form-inner"> 

        <? if ($sex == 0): ?> 
         <h2>MALE</h2> 
         <div class="yesno"> 
          <div class="section-description"> 
           <p>text</p> 
          </div> 
        <? elseif ($sex == 1): ?> 
         <h2>FEMALE</h2> 
         <div class="yesno"> 
          <div class="section-description"> 
           <p>text</p> 
          </div> 
        <? else: ?> 
         <h2>CHILDREN</h2> 
         <div class="yesno"> 
          <div class="section-description"> 
           <p>text</p> 
          </div> 
        <? endif; ?> 

和变量是那些:

$step = intval($_POST[ 'form_post' ]); // Gather completed step 
$sex = intval($_POST[ 'form_sex' ]); // Gather gender 

的想法是,当我点击该输入为“下一步”,在浏览器的URL被改变喜欢:http://xyz.com/survey/index.php?gender=0?step=1

,但如果我想提出确切的链接http://xyz.com/survey/index.php?gender=0?step=1在一个新的浏览器,所以我可以去步骤1在男性性别的,它不会,它会去索引no的步骤,请解决任何问题?你能帮助任何想法吗?

+0

通过'http://xyz.com/survey/index.php性别= 0&步= 1' – Peon 2012-08-07 12:03:38

+0

表单使用 '得到' 这样$ _POST ['form_sex']从来没有设置,使用$ _GET ['form_sex'] PS $步骤仍然不是$ step + 1的下一页 – Waygood 2012-08-07 12:06:42

+0

@Waygood最后更新是'

&step = <?echo $ step + 1;?>“method =”post“>'但不工作:( – Abude 2012-08-07 12:13:45

回答

1

您的URL有错误的参数。正确的语法是:中

http://xyz.com/survey/index.php?gender=0&step=1 

代替

http://xyz.com/survey/index.php?gender=0?step=1 

的UE &串更多的变数在一起。 ?仅用于第一个说URL的其余部分是变量。

更改这条线在你的PHP代码:

<form id="candida-form" action="index.php?gender=<? echo $sex; ?>?step=<? echo $step; ?>" method="get"> 

<form id="candida-form" action="index.php?gender=<? echo $sex; ?>&step=<? echo $step; ?>" method="get"> 

编辑:另外,更改$step = intval($_POST[ 'form_post' ]);到:

$step = intval($_POST[ 'step' ]); 

你没有得到你的变量回正常。

+0

由于表单为GET,这些参数会得到擦除?应该一步一个隐藏的输入呢? – Waygood 2012-08-07 12:09:29

+0

我试图把它放在你的方式,所以链接是像http://xyz.com/survey/index.php?gender=0&step=1,但不工作:(另一件事我把方法=“后”不是“得到”,因为它不工作(形式) – Abude 2012-08-07 12:09:47

+0

@Waygood不,它只是意味着其他任何东西都被附加到表单的'action'上。 – Fluffeh 2012-08-07 12:10:21

0

您的网址不正确。您需要使用&字符来分隔参数。不是另一个问号:

http://xyz.com/survey/index.php?gender=0?step=1 

应该

http://xyz.com/survey/index.php?gender=0&step=1 
+0

它不工作:(我试过,但不是与'&' – Abude 2012-08-07 12:11:18

+0

10任何想法,请帮助我吗?谢谢! – Abude 2012-08-07 15:47:13