Hallo!
Ich versuche per PHP einen $_POST-REQ an eine webseite zu schicken.
Mein Script
	
Nur kommt leider folgende Fehlermeldung:
	Liegts am Script?
							
						
					Ich versuche per PHP einen $_POST-REQ an eine webseite zu schicken.
Mein Script
PHP-Code:
	
	
     $data = "";
     $boundary = "---------------------".substr(md5(rand(0,32000)),0,10);
     $fp = fsockopen($host, 80);
     if($fp) {echo "OFFEN";}
 
     fputs($fp, "POST $path HTTP/1.1\n");
     
     fputs($fp, "Host: $host\n");
     
     // Ab dieser Stelle sammeln wir erstmal alle Daten in einem String
     // Sammeln der POST Daten
     foreach($postdata as $key => $val){
         $data .= "--$boundary\n";
         $data .= "Content-Disposition: form-data; name=\"".$key."\"\n\n".$val."\n";
     }
     $data .= "--$boundary\n";
 
 
     // Senden aller Informationen
     fputs($fp, "Content-length: ".strlen($data)."\n\n");
     
     fputs($fp, $data);
     $res = "";
     // Auslesen der Antwort
     while(!feof($fp)) {
         $res .= fread($fp, 1);
     }
     fclose($fp);
 
     return $res;
}
 
$postdata = array('name'=>'gustav85', 'betreff'=>'TESTmail', 'text'=>'DAS IST DER TEXT DAZU', 'switch'=>'msgInsert');
echo postToHost ("www.seite.de", 0, "schreiben.php", $postdata); 
Code:
	
	HTTP/1.1 400 Bad Request Date: Wed, 16 Mar 2011 21:54:21 GMT Server: Apache Vary: Accept-Encoding Content-Length: 297 Connection: close Content-Type: text/html; charset=iso-8859-1 Bad Request Your browser sent a request that this server could not understand.
 
          
 Moderatorin
 Moderatorin

Kommentar