Php $ _GET值来自另一个页面,但我不能在提交之后将$ _GET ['id']放在同一页面上

问题描述 投票:1回答:1

提交表单后,$ _GET值即帖子的id消失了。我怎样才能在提交之后把这个事件......以及所有形式的值...

php wordpress forms
1个回答
0
投票

您可以使用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'];
}
© www.soinside.com 2019 - 2024. All rights reserved.