I\'ve never used PHP but right now, I need to write a PHP file that displays in a log file the content of the body of a POST HTTP request.
I\'ve read that you can ac
The global variable is $_POST
, not _POST
. Also it might be that you are sending the data via GET
method, in which case you need to use the $_GET
global variable.
If you want to check for either POST
or GET
method, you can use the global variable $_REQUEST
. Sample code bellow:
<html>
<body>
<form method="POST" action="postdata.php">
<input type="text" name="mydata" />
<input type="submit">
</form>
</body>
</html>
file postdata.php:
<?php
$result = $_POST['mydata'];
echo $result;
$post_body = file_get_contents('php://input');
php://input
allows you to read raw POST data. It is a less memory intensive alternative to$HTTP_RAW_POST_DATA
and does not need any special php.ini directives.php://input
is not available with enctype="multipart/form-data".
(Source: http://php.net/wrappers.php)
Maybe you misspelled it. The array's correct name $_POST
.
Try this
<?php
var_dump($_POST);
and see what happens.