0

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!
Community
  • 1
  • 1
cmh
  • 271
  • 1
  • 4
  • 17
  • 2
    Might be a typo in your example, but you need `$_POST`, not `$_post`. PHP variable names are case sensitive. – Another Code Mar 18 '12 at 08:25
  • Note: `enctype="application/x-www-form-urlencoded"` is the default form encoding, you don't have to write it into your HTML, see http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 – hakre Mar 18 '12 at 08:25
  • If you don't mind, PLEASE STATE THE REASON WHY YOU VOTED DOWN,thanks! – cmh Mar 18 '12 at 21:54

1 Answers1

2

$_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.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • really !! The problem is solved. I should use upper case for $_POST['_id']. Thanks a lot ! – cmh Mar 18 '12 at 08:31