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 步,它不会,它会进入第 1 步的索引,请问有什么解决方案吗?你能帮忙吗?

4

2 回答 2

1

You have the URL wrong with parameters. The correct syntax is:

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

instead of

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

ues & to string more variables together. The ? is only used for the first to say that the rest of the URL is variables.

Change this line in your PHP code:

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

to

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

Edit: Also, change $step = intval( $_POST[ 'form_post' ] ); to:

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

You aren't getting your variable back properly.

于 2012-08-07T12:02:24.017 回答
0

Your URL is incorrect. You need to use the ampersand characters to separate paramters. Not another question mark:

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

should be

http://xyz.com/survey/index.php?gender=0&step=1
于 2012-08-07T12:02:51.367 回答