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に移動できるようにしたい場合、それはできません。ステップのインデックスに移動します。解決策はありますか? 何かアイデアがあれば教えてください。

4

2 に答える 2

1

URL のパラメータが間違っています。正しい構文は次のとおりです。

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

それ以外の

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

より多くの変数を一緒に並べる&必要があります。は?、残りの 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' ] );

変数を適切に取得していません。

于 2012-08-07T12:02:24.017 に答える
0

URL が正しくありません。パラメータを区切るには、アンパサンド文字を使用する必要があります。別の疑問符ではありません:

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

する必要があります

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