0

这不起作用。旧参数丢失。我得到http://xxxx/temp/test.php?mode=compound

<form align="right" action="http://<? echo $_SERVER['SERVER_ADDR']."/temp/test.php?".$_SERVER['QUERY_STRING'];?>">
<? if ($_SESSION['mode']=="simple") { ?>
<input type="submit" value="Switch to compound mode">
<input type="hidden" name="mode" value="compound">
<? } else { ?>
<input type="submit" value="Switch to simple mode">
<input type="hidden" name="mode" value="simple">
<? } ?>
</form>
4

2 回答 2

0

假设您正在使用 GET 参数,您可以尝试使用

echo $_SERVER['SERVER_ADDR']."/temp/test.php?".implode('&', $_GET);

代替

echo $_SERVER['SERVER_ADDR']."/temp/test.php?".$_SERVER['QUERY_STRING'];
于 2013-02-18T12:28:14.583 回答
0

我终于用这段代码做到了:

<form align="right" action="http://<?echo $_SERVER['SERVER_ADDR']."/temp/test.php";?>">
<? if ($_SESSION['mode']=="simple") { ?>
<input type="submit" value="Switch to compound mode">
<input type="hidden" name="mode" value="compound">
<? } else { ?>
<input type="submit" value="Switch to simple mode">
<input type="hidden" name="mode" value="simple"> <? } 
foreach ($_GET as $id=>$parameter) { if ($id=="mode") { continue;}?>
<input type="hidden" name="<?echo $id;?>" value="<?echo $parameter;?>" /> <? } ?>
</form>
于 2013-02-20T11:50:34.023 回答