post to server

burningodzilla
07-08-2002, 12:34 PM
can someone tell me how to send a post request and data to a server? i know the url and want to post to it directly, rather than sometin lame like:

url.open('http://www.poo.com/scr.pl?Poo=1")

what i mean is i dont want to "fake" a post by simply opening a new window with the target script as the url...or is that just how its done?

Thinker
07-08-2002, 09:52 PM
Is this really a PHP question? First off, a .pl file would be a Perl
script, next, submitting a form with the post method is a client
side thing. What language are you trying to use on the client to
do the post submit?

burningodzilla
07-09-2002, 12:35 PM
...ok. first off, this is PHP QUESTION. Let me clarify.

I have a form that posts to a php script, foo.php. the form consists of some variables:

...
<input type='hidden' name='var1' value='value1'>
<input type='hidden' name='var2' value='value2'>
...

now in the foo.php script the varaible "$var1" and "$var2" are available and contain the values "value1" and "value2", respectively. From here i would like to POST this data (var1,var2,..) to a remote webserver script. My question is how do i do that...FROM A PHP SCRIPT.

The example url i gave was arbitrary and just happened to look like a perl - that doesnt matter. Be it perl, c, or otherwise a cgi script, it is a script that accepts post data.

sorry for the lack of clarity :(

Derek Stone
07-09-2002, 03:29 PM
You can't submit a form via PHP. Its server-side, while forms are client side. The JavaScript below might be of some help:


<BODY onLoad="document.all.formName.submit()">


-CL

burningodzilla
07-10-2002, 07:04 AM
well actually you can...sorta. The actual "form" in my situation is posted from the client to my php script for a little processing, and then must be forwarded on to another server via post method - and i am 99% sure php can do this as its just a matter of setting up the connection and request.

perl and asp can BOTH perfrom post requests, and look like this:
PERL:

use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','https://www.somesite.com/cgi-bin/somescript';
$req->content_type('application/x-www-form-urlencoded');
$req->content($query); # $query is the data being forwarded
$req = $ua->request($req);

ASP:

set objHttp = Server.CreateObject("Msxml.ServerXMLHTTP")
objHttp.open "POST", "https://www.somesite.com/cgi-bin/somescript", false
objHttp.Send str 'where str is data being forwarded


if this isnt clear then i won't post anymore about it.

ChiefRedBull
07-10-2002, 02:17 PM
Heh, it's taken you three posts to explain the problem clearly. Nice one ;)

Some searching revealed this: http://www.phpbuilder.com/columns/matt20000305.php3

Derek Stone
07-10-2002, 05:48 PM
well actually you can...sorta

HTML forms are not POST requests. There is a difference, although rather small. You can not submit a form from the server.

-CL

burningodzilla
07-11-2002, 06:33 AM
chief - I thought the first two were plenty clear. thanx for the link the link - i've been to that site but i'll check that.

CL - HTML forms arent POST requests? Oh...what do you call them then? And about the server - it isnt submitting a form per se, but isnt it still communicating via post?

thanks a lot guys/gals

bobbob
11-06-2002, 07:19 PM
http://www.alt-php-faq.org/local/55/


<?
// Generate the request header
$ReqHeader =
"POST $URI HTTP/1.1\n".
"Host: $Host\n".
"Content-Type: application/x-www-form-urlencoded\n".
"Content-Length: $ContentLength\n\n".
"$ReqBody\n";

// Open the connection to the host
$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket)

$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket))

$Result[$idx++] = fgets($socket, 128);
}
//-------------------------------------------
?>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum