Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php $\u不带值的POST_Php_Forms - Fatal编程技术网

Php $\u不带值的POST

Php $\u不带值的POST,php,forms,Php,Forms,我试图用POST发送数据,但调用var\u dump函数时,结果是array(0) 其他表单使用带有AJAX的post方法,结果变量值正确,HTML不起作用 为什么会发生这种情况 表格: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http:/

我试图用POST发送数据,但调用
var\u dump
函数时,结果是
array(0)

其他表单使用带有AJAX的post方法,结果变量值正确,HTML不起作用

为什么会发生这种情况

表格:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>Untitled Document</title>
      </head>

      <body>
      <form target="_new" enctype='application/x-www-form-urlencoded' action="include/php/produtos/romaneio/prueba.php" method="post">
      <input type="text" value="12" id="a" />
      <input type="submit" />
      </form>
      </body>
      </html>

无标题文件
php:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <? var_dump($_POST);
    ?>
    </body>
    </html>

无标题文件

如果使用
name=
命名元素,则表单元素的值将仅添加到
$\u POST
。因此,添加
name=“d”
而不是
id=“d”

如果使用
name=
命名元素,则表单元素的值只会添加到
$\u POST
。因此,添加
name=“d”
而不是
id=“d”

您忘记了输入
a
name
;因此,表单没有可提交的内容

<form target="_new" enctype='application/x-www-form-urlencoded' action="include/php/produtos/romaneio/prueba.php" method="post">
   <input type="text" value="12" name="a" />
   <input type="submit" />
</form>


(id
id
属性用于其他内容,本地化为通过Javascript或CSS使用DOM。)

您忘记了给
输入一个
名称;因此,表单没有可提交的内容

<form target="_new" enctype='application/x-www-form-urlencoded' action="include/php/produtos/romaneio/prueba.php" method="post">
   <input type="text" value="12" name="a" />
   <input type="submit" />
</form>


(id
id
属性用于其他内容,本地化为通过Javascript或CSS处理DOM。)

为什么要转储
$GLOBALS
?您应该是var dumping
$\u POST
(或者至少是
$\u REQUEST
)[出于调试目的]。除非您启用了register globals(我强烈建议您不要使用)。@Brad:我也建议您不要使用
$globals
,尤其是因为它是JIT初始化的。然而,register globals与此无关:@TomalakGeret'kal:同意,我只是在看到人们在任何情况下使用
$globals
时感到担心耸耸肩:“其他使用AJAX的帖子可以正常工作,而HTML不起作用。”我没有得到这一点。停止使用毫无意义和无用的单词“work”,我出于其他原因或POSTO可能在的位置丢弃了$GLOBALS seaching,但是你是对的,我应该在这个例子中使用$u POST var,为什么你要转储var
$GLOBALS
?您应该是var dumping
$\u POST
(或者至少是
$\u REQUEST
)[出于调试目的]。除非您启用了register globals(我强烈建议您不要使用)。@Brad:我也建议您不要使用
$globals
,尤其是因为它是JIT初始化的。然而,register globals与此无关:@TomalakGeret'kal:同意,我只是在看到人们在任何情况下使用
$globals
时感到担心耸耸肩:“其他使用AJAX的帖子可以正常工作,而HTML不起作用。”我没有得到这一点。停止使用毫无意义和无用的单词“work”,我把$GLOBALS seaching甩在后面是因为其他原因,但你是对的,我应该在这个例子中使用$u POST var谢谢你们的回答谢谢你们的回答