从Http请求(POST)获取数据

i make http request (post) from a c++ applications to be recieved from a php script using wininet.

when i do something like this

<?php
$data = file_get_contents(php://input)
$file = fopen("log.txt","a+");
fwrite($file,$data);
?>

This works fine, but when i do something like this

<?php
    $buffer = $_POST['buffer'];
    $file = fopen("log2.txt","a+");
    fwrite($file,$buffer);
    fclose($file);  
?>

it just opens the log2.txt without writing any data to the file. i am wondering why, what seems to be the problem as it doesnt seem to show me any error from this end.