kw: simple php post, php get, poster un formulaire sans submit

<?php
// file: send_post.php
error_reporting(E_ALL & ~E_NOTICE);
$eol = "\r\n";
$errno = 0;
$errstr = '';
$data = 'username=fred&password=blabla';
$fid = fsockopen('localhost', 80, &$errno, &$errstr, 30);
if ($fid) {
fputs ($fid, "POST /tools/post/show_post.php HTTP/1.1$eol");
fputs ($fid, "HOST: localhost$eol");
fputs ($fid, "Connection: close$eol");
fputs ($fid, "Content-Type: application/x-www-form-urlencoded$eol");
 
// Use 'Content-Length' NOT 'Length' !
fputs ($fid, 'Content-Length: ' . strlen($data) . $eol);
fputs ($fid, $eol);
fputs ($fid, $data);
fputs ($fid, $eol);
fpassthru($fid);
}
 
?>

et le fichier qui reçoit:

<?php
// file: show_post.php
error_reporting(E_ALL & ~E_NOTICE);
 
echo "<pre>\n";
echo "------------ POST VARIABLES ----------\n";
print_r($HTTP_POST_VARS);
echo "------------ SERVER VARIABLES ----------\n";
print_r($HTTP_SERVER_VARS);
echo "</pre>\n";
?>
  • info/phpsendformwithoutsubmit.txt
  • Dernière modification: 2018/07/18 09:46
  • par radeff