I know this question has been already asked in the forum for several times but neither any of the answer worked for me. I still get empty string every time I try to send a data via a URL parameter.
This is the PHP code
<?php
if (!file_get_contents("data:,ok")) {
die("Houston, we have a stream wrapper problem.");
}
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
$tempArray = json_decode(file_get_contents('generated.json'), true);
array_push($tempArray, $data);
$jsonData = json_encode($tempArray);
file_put_contents('generated.json', $jsonData);
print "</pre>";
?>
<form method="post">
<input type="text" name="name" value="ok" />
<input type="submit" name="submit" value="submit"/>
</form>
Example of passing a variable using url parameter
http://localhost/tests/testtest.php?name=what
Output:
Notice: Undefined index: CONTENT_TYPE in C:\Apache24\htdocs\tests\testtest.php on line 5
CONTENT_TYPE:
DATA:
I have already set allow_url_fopen = On
, set the post_max_size = 8M
and still no hope. However when I try to send a data by click the submit button it send a raw data to the php (string(21) "name=ok&submit=submit"
).
Anyone care to help? Thanks!