Page 1 of 1
Asynchronous Server Side Post
Posted: Mon Sep 13, 2004 10:03 am
by virdei
I have a php page that will receive some variables from a form. I want this php page to then do an asynchronous server side post of some new variables to a third php page. I have done this before in vbscript but I can't seem to find a way to do this in PHP.
Page 1: has a form that will post some variables
Page 2: will receive this variables and post some new variables to a third php page. The post done from this page must be an asynchronous server side post. The post must be done from the php script.
Page 3: will receive the post from page 2 and this page is never seen by the end user.
I have done this before using vbscript but I can't replicate it with PHP. Below is my code in vbscript.
<%
xSeconPostValue = "variablename=variablevalue"
Set objHTTP = server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "post", "url"
objHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
objHTTP.send xSecondPostValue
%>
So the second page will post the values to the third page and this will be done asynchronously. This is all done in the server side so all actions are hidden to the end user.
Any help with this is greatly appreciated
Posted: Mon Sep 13, 2004 10:12 am
by CoderGoblin
Why do you need to do this ?
You seem to be adding extra work for no return.. The middle "page" needs to be called, downloaded just for the third page to work...
If you simply need to process additional variables place them in the code for your third (my second) php script. If you process the first page's values you can hide them from the user regardless.
You may want to look at PHP command "header", but as far as I am aware you can not send POST values with it. (Try a search as I am pretty sure this has been discussed before).
Posted: Mon Sep 13, 2004 10:27 am
by virdei
The reason I need to do this is because the second page and the third page are in two different locations at two different ip addresses. The second page will execute some code and make that post to the third page which will then execute another code in that server.
So basically, page 2 will run some code on server 2 in location 2 and then it will post some variables to page 3 and this page will run some code in server 3 in location 3. Hence, why i need the asynchronous server side post.
Posted: Mon Sep 13, 2004 10:32 am
by CoderGoblin
As I said searching on the forum may help you find what you need...
viewtopic.php?t=25500&highlight=send+post
Found with key words "send POST" with "Search for all terms" checked.
Posted: Mon Sep 13, 2004 12:33 pm
by Weirdan
check out the [php_man]curl[/php_man] extension
Posted: Mon Sep 13, 2004 1:48 pm
by virdei
if you have information on how i can do this using curl it would be much appreciated. Curl does seem to be like the best option but it seems a bit more complex to learn and understand. If you have code samples that would be very helpful.
Posted: Mon Sep 13, 2004 2:05 pm
by virdei
I made some tests using curl and it is a much better option. Thanks for the help.