post(ing) data without a form

From: Date: Sat, 05 Oct 2002 09:03:09 +0000
Subject: post(ing) data without a form
Groups: php.general 
Request: Send a blank email to php-general+get-118947@lists.php.net to get a copy of this message
OK, I'm attempting this again: header ( 'Location: ../test/test.php' ); sendByPost(); function sendByPost() { $host = "localhost"; $port = 80; $postdata = "field1=value1&field2=value2&field3=value3"; if ($sp = fsockopen($host, $port)) { fputs($sp,"POST /jotr/test/test.php HTTP/1.0\n"); fputs($sp,"Host: $host\n"); fputs($sp,"Content-type: application/x-www-form-urlencoded\n"); fputs($sp,"Content-length: ".strlen($postdata)."\n"); fputs($sp,"Connection: close\n\n"); fputs($sp,$postdata); fclose($sp); } } Pretty straight forward. Now here's the code for test.php: $temp1 = $_POST['field1']; $temp2 = $_POST['field2']; $temp3 = $_POST['field3']; print $temp1.' '.$temp2.' '.$temp3; But the data is not posting: Notice: Undefined index: field1 in c:\apache\htdocs\jotr\test\test.php on line 3 Notice: Undefined index: field2 in c:\apache\htdocs\jotr\test\test.php on line 4 Notice: Undefined index: field3 in c:\apache\htdocs\jotr\test\test.php on line 5 WTF is going on, shouldn't this work?

« previous php.general (#118947) next »