Reputation: 39
I am trying to send data with POST, but the result is array(0)
when the var_dump
function is called.
Other forms using post method with AJAX results on a correct value of the variables, and the HTML does not work.
Why could this be happening?
The form:
<!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>
The 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>
Upvotes: 0
Views: 78
Reputation: 385385
You forgot to give your input
a name
; the form thus has no submittable content.
<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>
(The id
attribute is for other stuff, localised to working with the DOM through, say, Javascript or CSS.)
Upvotes: 3
Reputation: 349232
The value of form elements will only be added to $_POST
if the elements are named using name=
. So, add name="d"
instead of id="d"
.
Upvotes: 3