Php HTML表单';s";行动“;不结转我的$\u获取数据

Php HTML表单';s";行动“;不结转我的$\u获取数据,php,html,forms,get,Php,Html,Forms,Get,我有一个HTML表单,充当“确认删除”页面,我的“后退”按钮正在播放 $string = "foo.php?id=" . $_POST['fooid'] . "&id2=" . $_POST['barid']; <!-- ^^ this ends up being "foo.php?id=1&id2=2" --> <form action='<?php echo $string; ?>'> <input type='subm

我有一个HTML表单,充当“确认删除”页面,我的“后退”按钮正在播放

$string = "foo.php?id=" . $_POST['fooid'] . "&id2=" . $_POST['barid'];

<!-- ^^ this ends up being "foo.php?id=1&id2=2" -->


<form action='<?php echo $string; ?>'>
    <input type='submit' value='Back'>
</form>
$string=“foo.php?id=”$_POST['fooid']。“&id2=”$_POST['barid'];

您需要将get变量置于隐藏输入的形式中,如下所示:

<form action='foo.php'>
    <input type="hidden" name="id" value="1" />
    <input type="hidden" name="id2" value="2" />
    <input type='submit' value='Back'>
</form>

或者您可以使用以下链接:

<a href="foo.php?id=1&id2=2">Back</a>

也许这不是最好的答案,但我想这样做:

  $string = "foo.php?id=" . $_POST['fooid'] . "&id2=" . $_POST['barid'];

    <!-- ^^ this ends up being "foo.php?id=1&id2=2" -->


    <form action='foo.php'>
<input type="hidden" name="fooid" value ="<php echo $_POST['fooid']; ?>" />
<input type="hidden" name="barid" value ="<php echo $_POST['barid']; ?>" /> 
        <input type='submit' value='Back'>
    </form>
$string=“foo.php?id=”$_POST['fooid']。“&id2=”$_POST['barid'];
这应该能正常工作


编辑:更改$\u GET na$\u POST

让我们从表单提交开始

接下来,让我们回顾一下$u GET和$u POST

总之,在
标记内,使用
method=“get”
method=“post”
。根据您发送数据的方法,只有一个超全局数组将由成功的控件填充。我相信查询字符串必须来自GET请求url(这可能是默认的),而不仅仅是插入
action=”“
属性的普通字符串。我可能对查询字符串有错误,但您还有另一个问题。您正在一页上使用两个表单。目前,我认为一次只能成功提交一个表单的控件

<form action='delete.php' method='post'>  <!-- FORM 1 -->
    <input type='hidden' name='xrayid' value='<?php $_POST['xrayid']?>'>
    <input type='submit' name='submit' value='Confirm Delete?'>
</form>
<form action='<?php echo $string; ?>'> <!-- FORM 2, add a method="" attribute -->
    <input type='submit' value='Back'>
</form>


我不明白你能解释一下吗..将
method='get'
添加到第二个表单中。@AndyG-我认为这不会有帮助,因为表单的方法的默认值是
get
,所以即使OP没有提到该属性,它也应该像对待
method='get'
一样对待它。否?@ofirbarch您可能是对的,我没有检查默认值,但该方法无论如何都应该存在。添加:是,默认值为GET。此页面显示为两个按钮“确认删除”和“返回”。返回按钮用于返回上一页,其中包含URL中所需的所有数据(例如xray.php?id=1&id2=2)。在上一页上,id=1表示visitid,id=2表示patientid,我的数据库中的内容决定了页面上显示的内容,我需要这些信息来显示页面。可能有兴趣知道
$\u GET
$\u SERVER['QUERY\u STRING']
是否会使用单表单方法由您的查询字符串填充。
<form action='delete.php' method='post'>  <!-- FORM 1 -->
    <input type='hidden' name='xrayid' value='<?php $_POST['xrayid']?>'>
    <input type='submit' name='submit' value='Confirm Delete?'>
</form>
<form action='<?php echo $string; ?>'> <!-- FORM 2, add a method="" attribute -->
    <input type='submit' value='Back'>
</form>