I have a form on my website that creates cookies in the header when the page loads. I am attempting to mimic a form post.
I get the following 2 errors when tring to simulate the post:
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/ on line 60
Warning: fsockopen(): unable to connect to http::80 in /var/ on line 60
Error 0 Success
The initial code on my page with the data I want to automatically send to my form is
the php file with the function info that should submit the form is:
why do I get the two errors above? Is it because I am suppose to send the cookies back in the form somehow?
The name of the cookie is PHPSESSID I believe
I have read an article on zend dot com about mimicking submission posts and am still lost. Any help given would be greatly appreciated.
Thanks
[URL unfurl="true"]http://www.zend.com/zend/spotlight/mimocsumissions.php?out=dynamicwebpages [/url]
I get the following 2 errors when tring to simulate the post:
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/ on line 60
Warning: fsockopen(): unable to connect to http::80 in /var/ on line 60
Error 0 Success
The initial code on my page with the data I want to automatically send to my form is
Code:
include("postit2.php");
require_once "HTTP/Request.php";
$req =& new HTTP_Request(" [URL unfurl="true"]http://www.abc.com/page.php");[/URL]
$data["dbType"] = "mysql";
$data["dbHost"] = "localhost";
$data["dbUser"] = "xxx";
$data["dbPass"] = "letmein";
$data["dbName"] = "me";
$result = post_it2($data, " [URL unfurl="true"]http://www.abc.com/page.php");[/URL]
if (isset($result["errno"])) {
$errno = $result["errno"];
$errstr = $result["errstr"];
echo "<B>Error $errno</B> $errstr";
exit;
} else {
for($i=0;$i< count($result); $i++) echo $result[$i];
}
?>
the php file with the function info that should submit the form is:
Code:
<?php
function post_it2($data, $URL) {
// Strip http:// from the URL if present
$URL = ereg_replace("^[URL unfurl="true"]http://",[/URL] "", $URL);
// Separate into Host and URI
$Host = substr($URL, 0, strpos($URL, "/"));
$URI = strstr($URL, "/");
// Form up the request body
$ReqBody = "";
while (list($key, $val) = each($data)) {
if ($ReqBody) $ReqBody.= "&";
$ReqBody.= $key."=".urlencode($val);
}
$ContentLength = strlen($ReqBody);
// Generate the request header
$ReqHeader =
"POST $URI HTTP/1.0\n".
"Host: $Host\n".
"User-Agent: PostIt\n".
"Content-Type: application/x-[URL unfurl="true"]www-form-urlencoded\n".[/URL]
"Content-Length: $ContentLength\n\n".
"$ReqBody\n";
// echo $ReqHeader;
// Open the connection to the host
$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket) {
$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket) && $Result[$idx-1] != "0\r\n") {
if (substr($Result[$idx-1], 0, 2) == "0\r\n") echo "The End:".strlen($Result[$idx-1]);
$Result[$idx++] = fgets($socket, 128);
}
return $Result;
}
?>
why do I get the two errors above? Is it because I am suppose to send the cookies back in the form somehow?
The name of the cookie is PHPSESSID I believe
I have read an article on zend dot com about mimicking submission posts and am still lost. Any help given would be greatly appreciated.
Thanks
[URL unfurl="true"]http://www.zend.com/zend/spotlight/mimocsumissions.php?out=dynamicwebpages [/url]