My goal is to pass data to the next page in the same way a form POST would, just without having to actually press the button. I know you can use cURL, but i'd rather stick to fsockopen. It seems easy enough, but I can't seem to get it to work. I know for a fact I'm using the correct URL and index.php is a working file. After I run the code below I get this error:
---------ERROR--------
Warning: fsockopen(): php_network_getaddresses: gethostbyname failed in c:\inetpub\wwwroot\manage\
add.php on line 13
Warning: fsockopen(): unable to connect to localhost/index.php:80 in c:\inetpub\wwwroot\manage\
add.php on line 13
ERROR: 0 - The operation completed successfully.
----------CODE-----------
SendPost("index.php");
function SendPost($url) {
$fp = fsockopen($_SERVER['HTTP_H
OST']."/".
$url, 80, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
fwrite($fp, "\n");
echo fread($fp, 26);
fclose($fp);
}
}
--------------
What am I doing wrong. I'm using windows XP and would like to get it running on my localhost before using it on my live server.
Since I get the error "ERROR: 0 - The operation completed successfully", php.net says it has something to do with "an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket."
http://us2.php.net/manual/en/function.fsockopen.php
Any answers to what I'm doing wrong????
$_SERVER['HTTP_HOST']."/".
=> eg. "www.example.com/url/you/access.php"
That part ."/".$url is too much to define a hostname
That is no valid hostname. I think the function that you want to use is
fopen($_SERVER['HTTP_HOST'