I have to write a php file that was supposed to receive data from a site form with post method . To test it i wrote these two files :
<?php
$url = 'temp.php';
$data = array('username' => 'jsafsd@gmail.com', 'password' => 'lassrd');
$query=http_build_query($data);
$options = array(
'header' => "Connection: close\r\n".
"Content-Length: ".strlen($query)."\r\n",
'method' => 'POST',
'content' => $query,
);
$context = stream_context_create(array ( 'http' => $options ));
$result = file_get_contents($url,false,$context);
var_dump($result);
?>
temp.php
<?php
if($_POST['username'] && $_POST['password'])
echo "hi";
else
echo "bye";
exit();
?>
But when i run the first file, all i get is string
<?php
if($_POST['username'] && $_POST['password'])
echo "hi";
else
echo "bye";
exit();
?>
(length=95)
What is the problem with this ?