Php $\u不带值的POST
我试图用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:/
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”
您忘记了输入的aname
;因此,表单没有可提交的内容
<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>
(idid
属性用于其他内容,本地化为通过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>
(idid
属性用于其他内容,本地化为通过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谢谢你们的回答谢谢你们的回答