dongma2388 2012-10-22 14:17
浏览 27
已采纳

提交表单时从URL获取?var =值

I have a form on a page which holds in the URL page?slot=1 and I want the form to correspond to the slot=1 value, but it doesn't seem to transfer over to the action="process.php" that I have set up.

Do you have any idea on how to capture which slot is selected, and then transfer that with the form submit?

(selected_battle.php takes slot=1 and makes it $selected_battle = 1; then the insert_battle_data.php says if selected_battle=1, use the form there to such and such. but it never gets the $selected_battle=2, only 1. the selected battle php is below as well. ) FORM CODE:

<?php
require("selected_battle.php");
?>
<div style="float:left; margin-left:-40px; margin-top:-153px;">





        <img src="../images/upload/btn_choosefile.png" border=0 style="margin-right:0px; float:right; margin-top:20px;"/>
        </div>
    </div>


    <div style="float:left; margin-left:-468px; margin-top:40px;">

     <form action="/controlpanel/insert_upload_battle_data.php" method="post" enctype="multipart/form-data">
     <?php if (isset($_GET['slot'])) { ?>
<input type="hidden" name="slot" value="<?php echo htmlspecialchars($_GET['slot']); } ?>">
    <input type="file" name="file" id="file" style="color:#FFFFFF; background-color: transparent; border-width: 0; border-color:transparent; border-style:hidden; width:240px; height:11px; padding-left:5px; margin-left: 428px; margin-top:-174px; float:left; font:'Lucida Console', Monaco, monospace; font-size:9px; padding-bottom:5px;" />



<input type="submit" name="submit" value="" class="ready_button" border="0" style="margin-left:683px; margin-top:-175px; float:left;" />

</div>

SELECTED BATTLE PHP

<?php
$selected_battle = 1;

if (!empty($_GET['slot'])) {
    $slot = implode(',', $_GET);

} else {
    $slot = 1;
}
echo $slot;




if ($slot == 1) {
  $selected_battle=1;
}

else if ($slot == 2) {
  $selected_battle=2;
}

else if ($slot == 3) {
  $selected_battle=3;
}

else if ($slot == 4) {
  $selected_battle=4;
}

else if ($slot == 5) {
  $selected_battle=5;
}

else if ($slot == 6) {
  $selected_battle=6;
}

else if ($slot == 'q') {
  $selected_battle=7;
}

?>
  • 写回答

3条回答 默认 最新

  • doufei9946 2012-10-22 14:19
    关注

    Just include it in the form using a hidden input.

    <form action="process.php">
    <?php if (isset($_GET['slot'])) { ?>
    <input type="hidden" name="slot" value="<?php echo htmlspecialchars($_GET['slot']); ?>">
    <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置