Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsCode:
<?
// http.inc by nf@bigpond.net.au
// http://nf.wh3rd.net/
function http_post($server, $port, $url, $vars) {
// example:
// http_post(
// "www.fat.com",
// 80,
// "/weightloss.pl",
// array("name" => "obese bob", "age" => "20")
// );
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)";
$urlencoded = "";
while (list($key,$value) = each($vars))
$urlencoded.= urlencode($key) . "=" . urlencode($value) . "&";
$urlencoded = substr($urlencoded,0,-1);
$content_length = strlen($urlencoded);
$headers = "POST $url HTTP/1.1
Accept: */*
Accept-Language: en-au
Content-Type: application/x-www-form-url
User-Agent: $user_agent
Host: $server
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: $content_length
";
$fp = fsockopen($server, $port, $errno, $errstr);
if (!$fp) {
return false;
}
fputs($fp, $headers);
fputs($fp, $urlencoded);
$ret = "";
while (!feof($fp))
$ret.= fgets($fp, 1024);
fclose($fp);
return $ret;
}
echo http_post("www.server.com"
?>
After help getting going on POSTing form data through a proxy written in PHP, I found this bit of code. I'm using it to log in to a phpBB board and the login is successful. The problem I've run into is that what is returned by the statement
return $ret;
is the header for the page that the phpBB login page redirects to (index.php). I need help figuring out how to continue the communication between the client and the server. I need to be able to pass cookie information back and forth to maintain the logged in state.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: sandoshvrPosted on 2003-12-21 at 23:41:22ID: 9983775
Comments are available to members only. Sign up or Log in to view these comments.