Hi everyone,
I'm having trouble sending POST headers to a server via a PHP script. This is what I'm getting back from the server:
Not Found
The requested URL /functions/Article.php was not found on this server.
Apache/1.3.27 Server at server1.control-access3.com Port 80
Now, I'm not too sure how that 404 is being generated as the file exists on the server...
I don't think there's anything wrong with my code, it works fine on my machine and on another server that it's on.
This is the code:
$sPostURL = "http://www.mysite.com/functions/Article.php?op=admin";
$sPostVars = "a=4";
$header .= "POST " . $sPostURL . " HTTP/1.0\r\n";
$header .= "Accept: */*\r\n";
$header .= "Accept-Language: en-au\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen($sPostVars) . "\r\n\r\n";
$fp = fsockopen("localhost", 80, $errno, $errstr, 30);
if(!$fp)
echo "$errstr ($errno)";
else{
fputs($fp, $header . $sPostVars);
while(!feof($fp))
$res .= fgets($fp, 1024);
fclose($fp);
}
preg_match("/<!DOCTYPE.*|<HTML>.*/is", $res, $aMatches);
echo $aMatches[0];
where $sPostURL is a valid URL
What could be causing this? It was working fine untill I tried the code on this new server I'm on... do you think it could be a configuration problem on their end?
Or does it have something to do with the headers I'm sending? I don't actually know a lot about HTTP headers, but I'm pretty sure there's nothing wrong with the ones I'm sending there...
it's so strange... if anyone has any idea what's going on, it would be much apreciated.
Thanks!
-Adam 🙂