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:
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?
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?
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 :(
07-09-2002, 03:29 PM
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:
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','https://www.somesite.com/cgi-bin/somescript';
$req->content($query); # $query is the data being forwarded
$req = $ua->request($req);
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.
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
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.
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
11-06-2002, 08:19 PM
// Generate the request header
"POST $URI HTTP/1.1\n".
// Open the connection to the host
$socket = fsockopen($Host, 80, &$errno, &$errstr);
$Result["errno"] = $errno;
$Result["errstr"] = $errstr;
$idx = 0;
$Result[$idx++] = fgets($socket, 128);