I had to do something similar to make a script that would send a message to my cell phone by POSTing variables to a web form on my cell phone providers site. I found a great HTTP_POST function, which I'll post below, along with the cell phone script as an example:
// http.inc by [email]nf@bigpond.net.au[/email]
// [url]http://nf.wh3rd.net/[/url]
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-urlencoded
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);
// I (examancer@cox.net) commented out these lines because they were causing the script to fail for my implementation, and weren't needed.
//$ret = "";
//while (!feof($fp))
// $ret.= fgets($fp, 1024);
fclose($fp);
return true;
}
function SendTextMessage ($message) {
$server = "mycricket.com";
//$message = "This is a test message buddy!";
$url = "/text/sendto_sms_system.asp?Step=2";
$vars = array(
"Cricket_Phone_Number" => "4026122567",
"from" => "4022911630",
"email_from" => "examancer@cox.net",
"msg" => $message//,
//"B1" => "Submit"
);
if (http_post($server, 80, $url, $vars)) {
return true;
} else {
return false;
}
}
if (SendTextMessage("Test message!!!")) {
echo("Successfully sent text message!");
} else {
echo("FAILED sending text message.");
}
so thats basically how you do it... take the vars submitted by the user and put them into an array... were you can rename them if need be and add on any variables you want.. then send them through the script and all should be well.