douzheng5717 2012-03-18 08:21
浏览 22
已采纳

为什么在发布的HTML表单文本字段中使用PHP端的$ _​​POST函数接收空数据[重复]

Possible Duplicate:
php $_POST array empty upon form submission

I just make a simple test to POST a HTML format's textfield data to PHP server. And, in PHP server side, just use the $_POST[] function to retrive the posted data. However, there is empty(null) data recevied always. Attached below are the HTML code and php script I tested. Appreaicted if you can point me where I was wrong?

----HTML code--- senddata.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=big5" />
<title>Untitled Document</title>
</head>

<body>
<form action="receivedata.php" method="post" enctype="application/x-www-form-urlencoded" name="form1" id="form1">
  <label>_id
  <input name="_id" type="text" id="_id" />
  </label>
  <br />
  <label>Send
  <input type="submit" name="Submit" value="Send" />
  </label>
</form>
</body>
</html>

---PHP Script----- receivedata.php

<?php  

echo $_SERVER['SERVER_NAME']."<BR/>" ;
$id = $_post['_id'];
if ( isset($id))
{
  echo "Data set ready!<br/>";
  echo "id=".$id."<br/>";      
}
else
{
  echo "Data set is not ready!<br>";
}
?>

and the result display on the browser:

192.168.0.108
Data set is not ready!
  • 写回答

1条回答 默认 最新

  • duanba8173 2012-03-18 08:25
    关注

    $_POST[] is not a function but language construct used to add items into $_POST array.
    While $_POST is a variable, though you are not using it anyway but whatever $_post variable instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果