Hi everyone,
I am trying to use a php script to send variables using POST to another script and I am having trouble. This is what I have so far but it does not work, there is no error message it just loads a blank html page.
<?php
$data = "variable=123";
$url = 'www.mysite.com';
$sock = fsockopen($url, 80);
set_socket_blocking($sock, 1);
$path = '/cgi-bin/gateway.cgi';
$request="HEAD $path HTTP/1.0\r\n";
$request.="HOST: $host\r\n";
$request.="$data";
$request.="\r\n";
fputs($sock, $request);
$out = "";
$out = fgets($sock,32000);
echo "$out";
?>
Any help would be great!
Posting Variables From Script?
Moderator: General Moderators
HEAD is not a valid http-request method, try POST instead.
I think you also need a 'Content-length:' header with the length of the sent body [that is strlen($data)]
between the header and the body part should/must be a blank-line (containing only \n)
A single \n instead of \r\nshould do.
this is the data I send to fetch the http-interface ripe-data
I think you also need a 'Content-length:' header with the length of the sent body [that is strlen($data)]
between the header and the body part should/must be a blank-line (containing only \n)
A single \n instead of \r\nshould do.
this is the data I send to fetch the http-interface ripe-data
Code: Select all
$body = 'form_type=simple&full_query_string=&searchtext='.$ip.'&do_search=Search';
$headers = "POST /perl/whois?%253F HTTP/1.0\n";
$headers .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\n";
$headers .= "Accept: */*\n";
$headers .= "Content-length: ".strlen($body)."\n";
$headers .= "\n";
$headers .= $body;