Home » Php » php – Sent post data by file_get_contents, post data readable by the client/browser?

php – Sent post data by file_get_contents, post data readable by the client/browser?

Posted by: admin February 25, 2020 Leave a comment

Questions:

if I use file_get_contents for sending post data to another .php with like the example given by the manual further down, could a visitor of this webpage have any possiblity to view/trace the post data that i send? Thanks

<?php

$postdata = http_build_query(
    array(
        'var1' => 'some content',
        'var2' => 'doh'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context = stream_context_create($opts);

$result = file_get_contents('http://example.com/submit.php', false, $context);

?>

https://www.php.net/manual/en/context.http.php

How to&Answers: