Hi!
I am trying to get a little bit less workload with the PostToHost-function.
Here is what I want to do: When someone signs up for my site and indicates that we wants to get the newsletter, I need to post the data the user submitted to two different hosts:
a) to my database
b) to topica.com
Right now I'd have to get the data I got by E-Mail (which is only an e-mail-address) and enter it into a form from topica manually.
So, here is my code, which isn't working:
<?
function PostToHost($host, $path, $data) {
$fp = fsockopen($host,80);
printf("Open!\n");
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, "$data\n");
printf("Sent!\n");
while(!feof($fp)) {
$res .= fgets($fp, 128);
}
printf("Done!\n");
fclose($fp);
return $res;
}
$data = "?digest=f&Submit=Submit&sublist=dummy@online-talks.de&invite=OPTOUT";
printf("Go!\n");
$x = PostToHost(
"www.topica.com",
"/lists/online-talks.de-english/importsub.pl",
$data
);
?>
Here is the data I see on my topica-form (the one where I enter data by myself usually):
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<FORM METHOD="POST" ACTION="/lists/online-talks.de-english/importsub.pl" ENCTYPE="multipart/form-data">
Addresses:<TEXTAREA NAME="sublist" ROWS=5 COLS=40 WRAP=PHYSICAL></TEXTAREA><br>
<INPUT TYPE=RADIO NAME=invite VALUE="OPTOUT" CHECKED>Add Directly to List
<SELECT NAME=digest>
<OPTION VALUE='F'>Individual Messages
</SELECT>
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit">
</FORM>
</BODY>
I hope someone can help. Thanks in advance.
Ciao
Sascha