这不起作用。旧参数丢失。我得到http://x.x.x.x/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>
答案 0 :(得分:0)
假设您正在使用GET参数,可以尝试使用
echo $_SERVER['SERVER_ADDR']."/temp/test.php?".implode('&', $_GET);
代替
echo $_SERVER['SERVER_ADDR']."/temp/test.php?".$_SERVER['QUERY_STRING'];
答案 1 :(得分: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>