【问题标题】:HTML, PHP: Variables doesn't show up after form submitHTML,PHP:表单提交后变量不显示
【发布时间】:2018-01-17 10:47:48
【问题描述】:

提交以下表单后,placeid=2 部分不会显示在 URL 中。请协助。

<form method="GET" action="localhost/place.php?placeid=2">
    <button class="yesbtn" type="submit">Yes</button>
</form>

【问题讨论】:

  • 你能把你的洞页贴出来吗?问题是当前页面没有找到$id。
  • $id 是从哪里来的?
  • $id 不影响。即使我将其更改为 placeid=2。它仍然没有出现。
  • place.php?代码也是

标签: php html


【解决方案1】:

这确实是你应该做的。在您的表单中使用 method="get" 将在 URL 字符串中显示查询参数,就像在您的原始表单中一样。

form.html:

<form action="localhost/place.php" method="get">
    <input type="submit" value="2" id="placeid" name="placeid">
</form>

【讨论】:

    【解决方案2】:

    只是在这里测试了所有内容,但如果您希望您的脚本正常工作。您必须使用 method="post"。否则将无法正常工作。

    我测试过

    <html>
        <head></head>
        <body>
            <form method="post" action="page.php?placeid=2">
                <button class="yesbtn" type="submit">Yes</button>
            </form>
        </body>
    </html>
    

    工作过http://paules.eu/form.php

    Ayoub Elyalaoui 的答案将适用于但您希望在操作中编码。

    【讨论】:

      【解决方案3】:

      要以这种方式提交参数,您还可以使用这样的隐藏字段:

      <input type="hidden" value="<?= $id ?>">
      

      【讨论】:

      • 如果我想通过 URL 传递值怎么办?
      • 如果您的表单中没有方法参数,它将在您的表单中,但如果您的表单中有 method="post" 则不会。
      猜你喜欢
      • 2019-09-29
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 2019-11-15
      相关资源
      最近更新 更多