<html>
<head>
<title>post</title>
</head>
<body>
<form Method='Post' Action="php">
<input name="haha" type="text" value=1>
<input name="yy" type="hidden" value=2>
<input name="zz" value=3>
</form>
<?php
foreach ($_POST as $key=>$value)
{
echo "Key: $key; Value: $value <br/>\n ";
}
echo $_POST["haha"];
echo $_POST["zz"];
echo $_POST["yy"];
?> </body>
</html>请问为什么我的post用foreach能成功,而后面直接用post不行
请帮忙解决谢谢饿
<head>
<title>post</title>
</head>
<body>
<form Method='Post' Action="php">
<input name="haha" type="text" value=1>
<input name="yy" type="hidden" value=2>
<input name="zz" value=3>
</form>
<?php
foreach ($_POST as $key=>$value)
{
echo "Key: $key; Value: $value <br/>\n ";
}
echo $_POST["haha"];
echo $_POST["zz"];
echo $_POST["yy"];
?> </body>
</html>请问为什么我的post用foreach能成功,而后面直接用post不行
请帮忙解决谢谢饿
单独运行你上面的程序,因为没有传值,所以不会有值。
if($_POST['cmd']=="go" ){
foreach($_POST as $key=>$value)
{
echo "Key: $key; Value: $value <br/>\n ";
}
echo $_POST["haha"];
echo $_POST["zz"];
echo $_POST["yy"];
}
?>
<html>
<head>
<title>post</title>
</head>
<body>
<form Method='Post' Action="cc.php">
<input type="hidden" name="cmd" value="go">
<input name="haha" type="text" value=1>
<input name="yy" type="hidden" value=2>
<input name="zz" value=3>
<input type="submit" value="go"/>
</form>
</body>
</html>
<html>
<head>
<title>post</title>
</head>
<body>
<form Method='Post' Action="php">//这个action 应该不是这样吧,或者改为类似a.php
<input name="haha" type="text" value=1>
<input name="yy" type="hidden" value=2>
<input name="zz" value=3>
///整个form结束了都没有提交按钮,不做提交,POST自然也就没有值了
</form>
<?php
foreach ($_POST as $key=>$value)
{
echo "Key: $key; Value: $value <br/>\n ";
}…
而且ACTION的值也不对
如果楼主想让值传递到当前页面,ACTION为空就可以了