【问题标题】:Php $_GET value is coming from another page, but i cant put that $_GET['id'] on the same page after submitting the fromPhp $_GET 值来自另一个页面,但在提交 from 后我无法将 $_GET['id'] 放在同一页面上
【发布时间】:2017-12-30 05:20:16
【问题描述】:

提交表单后,作为 post id 的 $_GET 值消失了。 我如何在提交后放置这个事件......也包含表单的所有值......

【问题讨论】:

  • 在此处发布您的代码。
  • 发布您的表单代码

标签: php wordpress forms


【解决方案1】:

您可以使用hidden fields 通过form submit 发送附加值。像这样:

<form action="myOtherFile.php" method="GET">
  <!-- put it anywhere inside the form and give it a desired name and value -->
  <input type="hidden" name="postId" value="PutValueHere" />    

  <!-- and the rest of the form -->
  <input type="text" name="address" value="" />
  <!-- and so on ... -->
  <input type="submit" value="Submit me" />
</form>

在接收的 PHP 文件中,你会得到这样的变量:

if(isset($_GET['postId']))
{
    echo "ID is: ".$_GET['postId'];
}

【讨论】:

  • @faysal 没问题。很高兴为您提供帮助。如果对您有用,请将我的答案标记为已接受。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多