RE: [PHP] post(ing) data without a form
| From: | Timothy J Hitchens | Date: | Sat, 05 Oct 2002 09:18:58 +0000 |
| Subject: | RE: [PHP] post(ing) data without a form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118948@lists.php.net to get a copy of this message | ||
The other thing.. the header will redirect and the rest won't happen???
> header ( 'Location: ../test/test.php' );
Just out of interest sake do you or not have register global on/off??
Timothy Hitchens (HITCHO)
tim@hitcho.com.au
HITCHO has Spoken!
-----Original Message-----
From: Pablo Oliva [mailto:poliva@cox.net]
Sent: Saturday, 5 October 2002 7:03 PM
To: php-general@lists.php.net
Subject: [PHP] post(ing) data without a form
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?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php