<bdo id='tEvQR'></bdo><ul id='tEvQR'></ul>
    <legend id='tEvQR'><style id='tEvQR'><dir id='tEvQR'><q id='tEvQR'></q></dir></style></legend>
  • <tfoot id='tEvQR'></tfoot>
  • <i id='tEvQR'><tr id='tEvQR'><dt id='tEvQR'><q id='tEvQR'><span id='tEvQR'><b id='tEvQR'><form id='tEvQR'><ins id='tEvQR'></ins><ul id='tEvQR'></ul><sub id='tEvQR'></sub></form><legend id='tEvQR'></legend><bdo id='tEvQR'><pre id='tEvQR'><center id='tEvQR'></center></pre></bdo></b><th id='tEvQR'></th></span></q></dt></tr></i><div id='tEvQR'><tfoot id='tEvQR'></tfoot><dl id='tEvQR'><fieldset id='tEvQR'></fieldset></dl></div>

  • <small id='tEvQR'></small><noframes id='tEvQR'>

        如何在表单提交时保留已设置的 GET 参数值?

        How to keep already-set GET parameter values on form submission?(如何在表单提交时保留已设置的 GET 参数值?)

        • <bdo id='plJOr'></bdo><ul id='plJOr'></ul>
            <tbody id='plJOr'></tbody>

              1. <legend id='plJOr'><style id='plJOr'><dir id='plJOr'><q id='plJOr'></q></dir></style></legend>

                1. <small id='plJOr'></small><noframes id='plJOr'>

                  <tfoot id='plJOr'></tfoot>
                  <i id='plJOr'><tr id='plJOr'><dt id='plJOr'><q id='plJOr'><span id='plJOr'><b id='plJOr'><form id='plJOr'><ins id='plJOr'></ins><ul id='plJOr'></ul><sub id='plJOr'></sub></form><legend id='plJOr'></legend><bdo id='plJOr'><pre id='plJOr'><center id='plJOr'></center></pre></bdo></b><th id='plJOr'></th></span></q></dt></tr></i><div id='plJOr'><tfoot id='plJOr'></tfoot><dl id='plJOr'><fieldset id='plJOr'></fieldset></dl></div>

                  本文介绍了如何在表单提交时保留已设置的 GET 参数值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 URL:foo.php?name=adam&lName=scott,在 foo.php 中我有一个表单,它给了我 矩形长度 &rectangleBreadth 带有提交按钮.

                  I have a URL : foo.php?name=adam&lName=scott, and in foo.php I have a form which gives me values of rectangleLength & rectangleBreadth with a submit button.

                  当我点击表单操作为 $_SERVER['REQUEST_URI'] 的提交按钮时,我得到这个结果 URL:foo.php?rectangleLength=10&rectangleBreadth=5代码>(这些值已由用户填写).

                  When I click this submit button with form action as $_SERVER['REQUEST_URI'], I get this result URL: foo.php?rectangleLength=10&rectangleBreadth=5 (these values have been filled in by the user).

                  请注意,我丢失了以前的值 name &lName 来自 URL.

                  Notice that I am losing my previous values name & lName from the URL.

                  我怎样才能保留它们?

                  另外,请记住,我必须回到 foo.php,如果用户想再次提交表单,那么长度和宽度值应该改变.

                  Also, keep in mind that I have to come back to foo.php and if the user wants to submit the form again then the length and breadth values should change.

                  推荐答案

                  您可以在第一个目标站点的表单中添加两个隐藏字段,在您的情况下为 blabla.php:

                  You can add two hidden fields in the form on the first target site, blabla.php in your case:

                  <form ...>
                    <input type="hidden" name="name" value="<?php echo htmlspecialchars($_GET['name']);?>">
                    <input type="hidden" name="lName" value="<?php echo htmlspecialchars($_GET['lName']);?>">
                  
                    <!-- rest of the form here -->
                  </form>
                  

                  对于动态解决方案,请使用 foreach 循环:

                  For a dynamic solution, use a foreach loop:

                  <?php
                  foreach($_GET as $name => $value) {
                    $name = htmlspecialchars($name);
                    $value = htmlspecialchars($value);
                    echo '<input type="hidden" name="'. $name .'" value="'. $value .'">';
                  }
                  ?>
                  

                  您可以考虑将动态方法锁定到已知可能键的列表:

                  You may consider locking the dynamic approach down to a list of known possible keys:

                  <?php
                  $keys = array('name', 'lName', ...);
                  foreach($keys as $name) {
                    if(!isset($_GET[$name])) {
                      continue;
                    }
                    $value = htmlspecialchars($_GET[$name]);
                    $name = htmlspecialchars($name);
                    echo '<input type="hidden" name="'. $name .'" value="'. $value .'">';
                  }
                  ?>
                  

                  这篇关于如何在表单提交时保留已设置的 GET 参数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)

                  • <bdo id='DvZJh'></bdo><ul id='DvZJh'></ul>
                    <tfoot id='DvZJh'></tfoot>
                      <i id='DvZJh'><tr id='DvZJh'><dt id='DvZJh'><q id='DvZJh'><span id='DvZJh'><b id='DvZJh'><form id='DvZJh'><ins id='DvZJh'></ins><ul id='DvZJh'></ul><sub id='DvZJh'></sub></form><legend id='DvZJh'></legend><bdo id='DvZJh'><pre id='DvZJh'><center id='DvZJh'></center></pre></bdo></b><th id='DvZJh'></th></span></q></dt></tr></i><div id='DvZJh'><tfoot id='DvZJh'></tfoot><dl id='DvZJh'><fieldset id='DvZJh'></fieldset></dl></div>
                    • <legend id='DvZJh'><style id='DvZJh'><dir id='DvZJh'><q id='DvZJh'></q></dir></style></legend>

                        <small id='DvZJh'></small><noframes id='DvZJh'>

                              <tbody id='DvZJh'></tbody>