日期:2014-05-17  浏览次数:20379 次

$_POST['text']获取表单输入框里的内容失败,怎么回事
本帖最后由 xuzuning 于 2012-05-14 16:17:54 编辑
<form method ='post' action='xiugaipop.php?id=7&c=5'>修改为:<input  type='text' name='text' style='width:170px' value='1月26日、5月5日'><input type='submit' value='确定修改'>
<input type='button' value='取消' onclick='cancel()'>
</form>

xiugaipop.php内容如下:
<? 
echo "n1=";
echo $n1=$_GET['id'];
echo "<br>";

echo "n2=";
echo $n2=$_GET['c'];
echo "<br>";


echo $_POST['text'];
echo "<br>";
?>

 

------解决方案--------------------
form的提交方式为get必用$_GET来取值。
------解决方案--------------------
引用:
<input  type='text' name=‘text’ style='width:170px' value='1月26日、5月5日'>

楼主的name=‘text’中的引号为中文字符,改为:

<input type='text' name='text' style='width:170px' value='1月26日、5月5日'>

------解决方案--------------------
测试毫无问题。
------解决方案--------------------
最简单的方法把
<form method ='post'
改成
<form method ='get'
------解决方案--------------------
程序木有问题啊,可以获取啊

<form method ='post' action='a.php?id=7&c=5'>修改为:<input type='text' name='text' style='width:170px' value='1月26日、5月5日'><input type='submit' value='确定修改'>
<input type='button' value='取消' onclick='cancel()'>
</form>
<?php var_dump($_GET);var_dump($_POST);?>

array(2) { ["id"]=> string(1) "7" ["c"]=> string(1) "5" } array(1) { ["text"]=> string(20) "1月26日、5月5日" } 
------解决方案--------------------